This patch makes test.c account for sub-second precision when checking modification dates in -nt and -ot
- Oliver Webb <[email protected]>
From 0bdb57a8242c45ced0bf29155a82b9244076c2d8 Mon Sep 17 00:00:00 2001 From: Oliver Webb <[email protected]> Date: Tue, 6 Aug 2024 12:51:08 -0500 Subject: [PATCH] test -nt -ot: nanoseconds --- coreutils/test.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/coreutils/test.c b/coreutils/test.c index 008d90b25..f4b612235 100644 --- a/coreutils/test.c +++ b/coreutils/test.c @@ -628,9 +628,13 @@ static int binop(void) if (stat(opnd1, &b1) || stat(opnd2, &b2)) return 0; /* false, since at least one stat failed */ if (op->op_num == FILNT) - return b1.st_mtime > b2.st_mtime; + return b1.st_mtime > b2.st_mtime || + (b1.st_mtime == b2.st_mtime && + b1.st_mtim.tv_nsec > b2.st_mtim.tv_nsec); if (op->op_num == FILOT) - return b1.st_mtime < b2.st_mtime; + return b1.st_mtime < b2.st_mtime || + (b1.st_mtime == b2.st_mtime && + b1.st_mtim.tv_nsec < b2.st_mtim.tv_nsec); /*if (op->op_num == FILEQ)*/ return b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino; } -- 2.46.0
_______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
