mirror of
https://codeberg.org/landley/toybox.git
synced 2026-01-26 14:13:25 +00:00
test -nt and -ot treat existing file as always newer than missing.
This commit is contained in:
parent
66fabe6c31
commit
84749b1b7f
@ -122,9 +122,14 @@ testcmd "-ef link" "newfile -ef samefile && echo yes" "yes\n" "" ""
|
||||
testcmd "-ef2" "newfile -ef oldfile || echo no" "no\n" "" ""
|
||||
testcmd "-ot" "oldfile -ot newfile && echo yes" "yes\n" "" ""
|
||||
testcmd "-ot2" "oldfile -ot oldfile || echo no" "no\n" "" ""
|
||||
testcmd "-ot3" "none -ot oldfile && echo yes" "yes\n" "" ""
|
||||
testcmd "-ot4" "oldfile -ot none || echo no" "no\n" "" ""
|
||||
testcmd "-ot5" "none -ot none || echo no" "no\n" "" ""
|
||||
testcmd "-nt" "newfile -nt oldfile && echo yes" "yes\n" "" ""
|
||||
testcmd "-nt2" "oldfile -nt newfile || echo no" "no\n" "" ""
|
||||
testcmd "-nt2" "oldfile -nt newfile || echo no" "no\n" "" ""
|
||||
testcmd "-nt3" "none -nt newfile || echo no" "no\n" "" ""
|
||||
testcmd "-nt4" "oldfile -nt none && echo yes" "yes\n" "" ""
|
||||
testcmd "-nt5" "none -nt none || echo no" "no\n" "" ""
|
||||
|
||||
testing "positional" "test -a == -a && echo yes" "yes\n" "" ""
|
||||
testing "! stacks" 'test \! \! \! \! 2 -eq 2 && echo yes' "yes\n" "" ""
|
||||
|
||||
@ -87,8 +87,11 @@ static int do_test(char **args, int *count)
|
||||
a = atolx(args[0]);
|
||||
b = atolx(args[2]);
|
||||
} else {
|
||||
if ((i == 12 ? stat : lstat)(args[0], &st1)
|
||||
|| (i == 12 ? stat : lstat)(args[2], &st2)) return 0;
|
||||
int j = (i == 12 ? stat : lstat)(args[0], &st1),
|
||||
k = (i == 12 ? stat : lstat)(args[2], &st2);
|
||||
|
||||
// "does not exist" is always older than existing file
|
||||
if (j || k) return (i<14) ? 0 : i==16 ? j>k : j<k;
|
||||
}
|
||||
|
||||
if (!i) return a == b;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user