Download raw body.
ksh: use nanosecond resolution in the test builtin
On Sun, 23 Mar 2025 23:29:58 -0700, Collin Funk wrote:
> The ksh test builtin does not support nanosecond resolution which is
> possible with the timespec structure.
>
> This caused a failure in the autoconf test suite, but that can easily be
> fixed with a sleep.
I think we want to retain the existing behavior for when the file
doesn't exist. That would look something like this.
- todd
Index: bin/ksh/c_test.c
===================================================================
RCS file: /cvs/src/bin/ksh/c_test.c,v
diff -u -p -u -r1.28 c_test.c
--- bin/ksh/c_test.c 10 Jun 2023 07:24:21 -0000 1.28
+++ bin/ksh/c_test.c 24 Mar 2025 20:05:43 -0000
@@ -327,7 +327,8 @@ test_eval(Test_env *te, Test_op op, cons
*/
return stat(opnd1, &b1) == 0 &&
(((s2 = stat(opnd2, &b2)) == 0 &&
- b1.st_mtime > b2.st_mtime) || s2 < 0);
+ timespeccmp(&b1.st_mtim, &b2.st_mtim, >)) ||
+ s2 != 0);
}
case TO_FILOT: /* -ot */
{
@@ -337,7 +338,8 @@ test_eval(Test_env *te, Test_op op, cons
*/
return stat(opnd2, &b2) == 0 &&
(((s1 = stat(opnd1, &b1)) == 0 &&
- b1.st_mtime < b2.st_mtime) || s1 < 0);
+ timespeccmp(&b1.st_mtim, &b2.st_mtim, <)) ||
+ s1 != 0);
}
case TO_FILEQ: /* -ef */
return stat (opnd1, &b1) == 0 && stat (opnd2, &b2) == 0 &&
ksh: use nanosecond resolution in the test builtin