Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cakebaker
Copy link
Contributor

@cakebaker cakebaker commented Nov 12, 2025

This PR changes the behavior of -nt (newer than) and -ot (older than) so that an existing file is newer than a non-existing file and a status of 0 (true) is returned. So far we always returned a status of 1 (false) if a non-existing file was specified.

Now it matches the behavior of GNU test (see also https://www.gnu.org/software/coreutils/manual/html_node/File-characteristic-tests.html):

$ ../gnu/src/test README.md -nt non_existing
$ echo $?
0
$ ../gnu/src/test non_existing -nt README.md
$ echo $?
1
$ ../gnu/src/test README.md -ot non_existing
$ echo $?
1
$ ../gnu/src/test non_existing -ot README.md
$ echo $?
0

This issue was originally reported in https://bugs.launchpad.net/ubuntu/+source/rust-coreutils/+bug/2131117

@cakebaker cakebaker force-pushed the test_ot_nt_with_non_existing_file branch from 1808a37 to 75478e5 Compare November 12, 2025 15:53
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

existing -nt non-existing => true
non-existing -nt existing => false
existing -ot non-existing => false
non-existing -ot existing => true
@cakebaker cakebaker force-pushed the test_ot_nt_with_non_existing_file branch from 75478e5 to e502d89 Compare November 13, 2025 15:43
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@cakebaker cakebaker requested a review from sylvestre November 14, 2025 07:53
@sylvestre sylvestre merged commit 8b49900 into uutils:main Nov 15, 2025
172 of 176 checks passed
@cakebaker cakebaker deleted the test_ot_nt_with_non_existing_file branch November 16, 2025 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants