| Summary: | -nt/-ot in test(1) does not detect if tv_nsec are different | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | hburch <hburch> | ||||
| Component: | bin | Assignee: | dwmalone | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | 5.0-CURRENT | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
Responsible Changed From-To: freebsd-bugs->dwmalone Patch looks sensible - I'll have a look at it. State Changed From-To: open->closed Patch applied to -current and -stable. Thanks. |
Because newerf only checks st_mtime, if the files have the same value for st_mtimespec.tv_sec but not for st_mtimespec.tv_nsec, test will improperly say that the files have the same modification time. This may be required for POSIX conformance, but that seems unlikely. Fix: Add code to newerf to check both st_mtimespec.tv_sec and st_mtimespec.tv_nsec. The old way was using the st_mtime hook, so switched it to st_mtimespec.tv_sec for consistency. Change olderf to just a call to newerf with the parameters reversed to reduce code duplication. Diff from current head (src/bin/test/test.c 1.47) How-To-Repeat: $ touch a ; echo pass time; touch b Expect: pass time Received: pass time $ test b -nt a && echo NEWER Expect: NEWER Received: [blank] (if the second does not increment, which is ~99.7% of the time on my system)