bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

test builtin of bash is not using nanosecond timestamps


From: werner
Subject: test builtin of bash is not using nanosecond timestamps
Date: Tue, 6 Mar 2012 13:22:51 +0100

Configuration Information [Automatically generated, do not change]:
Machine: i586
OS: linux-gnu
Compiler: gcc -I/usr/src/packages/BUILD/bash-4.2 
-L/usr/src/packages/BUILD/bash-4.2/../readline-6.2
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i586' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i586-suse-linux-gnu' 
-DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -march=i586 -mtune=i686 
-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector 
-funwind-tables -fasynchronous-unwind-tables -g -D_LARGEFILE64_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DRECYCLES_PIDS -Wall -g -std=gnu89 
-Wextra -Wno-unprototyped-calls -Wno-switch-enum -Wno-unused-variable 
-Wno-unused-parameter -ftree-loop-linear -pipe -fprofile-use
uname output: Linux boole 2.6.27.48-0.2-pae #5 SMP Fri Sep 24 16:09:41 CEST 
2010 i686 i686 i386 GNU/Linux
Machine Type: i586-suse-linux-gnu

Bash Version: 4.2
Patch Level: 20
Release Status: release

Description:
        As in subject the test builtin does not use the nanosecond timestamps
        of the stat structure specified in POSIX.1-2008.  The patch included
        shouls add the comparision of the nanosecond timestamps.

Repeat-By:
        touch /tmp/foo1 ; usleep 1 ; touch /tmp/foo2
        test /tmp/foo2  -nt /tmp/foo1 || echo Oops

Fix:
--- test.c
+++ test.c      2012-03-06 11:14:00.149934027 +0000
@@ -309,8 +309,17 @@ filecomp (s, t, op)
   
   switch (op)
     {
+#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || (defined(_XOPEN_SOURCE) 
&& ((_XOPEN_SOURCE - 0) >= 700)) || (defined(_POSIX_C_SOURCE) && 
((_POSIX_C_SOURCE - 0) >= 200809L))
+# define st_mtimcmp(t1, t2, CMP)                   \
+       (((t1).st_mtim.tv_sec == (t2).st_mtim.tv_sec) ?     \
+           ((t1).st_mtim.tv_nsec CMP (t2).st_mtim.tv_nsec) :       \
+           ((t1).st_mtim.tv_sec  CMP (t2).st_mtim.tv_sec))
+    case OT: return (r1 < r2 || (r2 == 0 && st_mtimcmp(st1, st2, <)));
+    case NT: return (r1 > r2 || (r1 == 0 && st_mtimcmp(st1, st2, >)));
+#else
     case OT: return (r1 < r2 || (r2 == 0 && st1.st_mtime < st2.st_mtime));
     case NT: return (r1 > r2 || (r1 == 0 && st1.st_mtime > st2.st_mtime));
+#endif
     case EF: return (same_file (s, t, &st1, &st2));
     }
   return (FALSE);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]