Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15098 > unrolled thread

Re: file access time and file modification time

Started byChet Ramey <chet.ramey@case.edu>
First post2019-07-09 10:48 -0400
Last post2019-07-09 10:48 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: file access time and file modification time Chet Ramey <chet.ramey@case.edu> - 2019-07-09 10:48 -0400

#15098 — Re: file access time and file modification time

FromChet Ramey <chet.ramey@case.edu>
Date2019-07-09 10:48 -0400
SubjectRe: file access time and file modification time
Message-ID<mailman.629.1562683938.2688.bug-bash@gnu.org>
On 7/9/19 6:16 AM, kfm@plushkava.net wrote:

>> Did you have a look at the 'conditional.sh' script too? Looks like the '-N' switch compares only the integer part of the timestamp seconds.
> 
> The stat structure supports timestamp fields of nanosecond granularity since POSIX.1-2008, so it should work. I tried a simple test case here, and the behaviour of -N seems generally broken:
> 
> # f=$(mktemp); [[ -N $f ]]; echo $?; touch -m "$f"; [[ -N $f ]]; echo $?
> 0
> 0
> 
> I expected the value of $? to be non-zero at first, followed by 0 after updating the mtime. 

The code just returns (atime <= mtime), and has since 1997. It uses the
st_atime and st_mtime fields. I should update it to use timespecs if
they're available, and (mtime > atime) might work closer to your
expectations.

After the call to mktemp, the atime and mtime are the same, so the test
returns true.

Using the test command that ships with GNU coreutils (v8.31) exhibits the
same problem:
> 
> # f=$(mktemp); command test -N "$f"; echo $?; touch -m "$f"; command test -N "$f"; echo $?
> 0
> 0

It might, but that's not what you tested. This runs the builtin test.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web