Public bug reported:

The -nt operator in the /usr/bin/test command does not handle non-
existent files correctly.

The OpenGroup standard says:

        pathname1 -nt pathname2

    True if pathname1 resolves to an existing file and pathname2 cannot
be resolved, or if both resolve to existing files and pathname1 is newer
than pathname2 according to their last data modification timestamps;
otherwise, false.

So given:

root@b78766553a96:~# touch foo
root@b78766553a96:~# rm -f bar
root@b78766553a96:~# ls -ld foo bar
ls: cannot access 'bar': No such file or directory
-rw-r--r-- 1 root root 0 Nov 12 01:58 foo

The command test foo -nt bar should succeed.

For the bash builtin, it does:

root@b78766553a96:~# test foo -nt bar; echo $?
0

But the /usr/bin/test command fails:

root@b78766553a96:~# /usr/bin/test foo -nt bar; echo $?
1

Package versions are:

root@b78766553a96:~# dpkg -S /usr/bin/test
coreutils-from-uutils: /usr/bin/test
root@b78766553a96:~# ls -l /usr/bin/test
lrwxrwxrwx 1 root root 31 Sep 26 18:16 /usr/bin/test -> 
../lib/cargo/bin/coreutils/test
root@b78766553a96:~# dpkg -S /usr/lib/cargo/bin/coreutils/test
rust-coreutils: /usr/lib/cargo/bin/coreutils/test
root@b78766553a96:~# dpkg -l coreutils-from-uutils rust-coreutils
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                  Version          Architecture Description
+++-=====================-================-============-==========================================
ii  coreutils-from-uutils 0.0.0~ubuntu24   all          coreutils from the 
uutils project
ii  rust-coreutils        0.2.2-0ubuntu2.1 amd64        Universal coreutils 
utils, written in Rust

Ubuntu version:

root@b78766553a96:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=25.10
DISTRIB_CODENAME=questing
DISTRIB_DESCRIPTION="Ubuntu 25.10"

(Note: Tested this in a docker image. This is a hard blocker for me to
update my WSL.)

** Affects: rust-coreutils (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2131117

Title:
  Rust coreutils test command doesn't report existing file is newer than
  non-existent file

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/rust-coreutils/+bug/2131117/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to