bug-bash
[Top][All Lists]
Advanced

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

Re: bash conditional expressions


From: Dale R. Worley
Subject: Re: bash conditional expressions
Date: Sun, 14 Nov 2021 21:57:49 -0500

Mischa Baars <mjbaars1977.backup@gmail.com> writes:
> Using Fedora 32 (bash 5.0.17) this returns a true, while on Fedora 35 (bash
> 5.1.8) this returns a false:
> touch test; if [[ -N test ]]; then echo true; else echo false; fi;

Well, looking at the manual page, I see 

       -N file
              True  if  file  exists  and  has been modified since it was last
              read.

so it's clear what "-N" tests, in terms of the access and modification
times of the file:  mod time > access time

One thing you have to worry about is how "touch" behaves, and whether
*that* has changed between Fedora versions.  I've run a few test uses of
"touch" (in Fedora 34) and examined the consequences with "stat", and
it's not clear to me exactly how "touch" behaves.

In any case, to report an error against bash, you need to show what the
modification and access times of the file are, and that -N does not
behave as specified with regard to the file.

In addition, as others have noted, the conventional build-control
program "make" compares the modification time of the "output" file
against the modification time of the "input" file, and uses that to
control whether to reexecute a build step.  It never looks at access
times.  This suggests you might want to reconsider whether "-N" is
performing the best possible test for your application.

Dale



reply via email to

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