test -nt and -ot ignore the subsecond part of file timestamps

Bug #1855325 reported by Sam Kendall
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mksh
Fix Released
Low
Thorsten Glaser

Bug Description

Example on Linux (RHEL 8):

$ touch a; sleep 0.1; touch b
$ ls --full-time a b
-rw-r--r-- 1 kendall staff 0 2019-12-05 13:41:43.483652556 -0500 a
-rw-r--r-- 1 kendall staff 0 2019-12-05 13:41:43.585652744 -0500 b
$ if [ a -ot b ]; then print older; fi
$ if [[ a -ot b ]]; then print older; fi
$

The last two commands should have printed "older".

$ print $KSH_VERSION
@(#)MIRBSD KSH R56 2018/01/14
$ uname -sr
Linux 4.18.0-80.el8.x86_64

R49 on Cygwin and R46 on RHEL 7 have the same behavior.

Revision history for this message
Sam Kendall (sckendall) wrote :

-nt and -ot are Korn extensions, so there's no POSIX standard behavior to conform to.

On RHEL 7 and 8, ksh93 and bash do *not* have the bug. On my old-ish version of Cygwin, bash *does* have the bug.

Revision history for this message
Thorsten Glaser (mirabilos) wrote :

My first reaction was “yes, there are operating systems with sub-second timestamps, but I don’t know whether I want to act differently depending on whether the OS does it or not”. But then, Stéphane wrote over the mailing list - https://<email address hidden>/msg00970.html - that POSIX is likely to add this, so I guess we’ll have to bite the bullet and do so.

Note that many tools and file formats (e.g. in the case of archivers) will continue to not handle sub-second timestamps, and that introducing tools that do support it *will* cause inconsistency (e.g. after unarchiving, or synchronising from another machine).

Thanks for reminding about the issue.

Changed in mksh:
assignee: nobody → Thorsten Glaser (mirabilos)
importance: Undecided → Low
status: New → Confirmed
Changed in mksh:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.