Path: csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: "" Newsgroups: gnu.bash.bug Subject: Re: file access time and file modification time Date: Tue, 9 Jul 2019 11:16:16 +0100 Lines: 33 Approved: bug-bash@gnu.org Message-ID: References: <20190708092807.02edd68a60130b89a7775425@plushkava.net> <20190709111616.26148014b42ea4210f634e1e@plushkava.net> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1562667390 20125 209.51.188.17 (9 Jul 2019 10:16:30 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org To: Mischa Baars Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plushkava.net; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=fm3; bh= Dc5422wrrC1lMA6KrQ3ElJr29zc1goAuVSlN5sQMeNc=; b=NDFfEujUpXnxjMzZ QjUqdIfRkKTZiNt36ucASCOtCLgUXtiGZUv9I9QfbWRUisM6vLi4xThrHWjAe2dM w0/KjisITxFe5ByuUx4ctLN/1KJ+qDfhpnDLh/L5gnLjP/wyHNq9EucLcbA+96qz c+6RIW98fm7wOHzb7iSWWY7cZSXf9msD5Irt0Zk5QxMaYjyq4t959dWop1Yn3UbK FUzZb7qtUZVI3RNnIwLmQWOZfXNGBSq+mvqaX6mx5/F8jIRDsd7BIb/S/SaRPHLu P1dUzCzyacPNmgNk6PAVNNKM7VQ1AeMG6zy0e783o0dtxSspGxAWpITMqpoUgcu/ POZhpw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=Dc5422wrrC1lMA6KrQ3ElJr29zc1goAuVSlN5sQMe Nc=; b=xcEonyxWIS/luQjCJNI6L6XsWHESO0q2/CFiHYHrCuiWM6+WUHh4HF8cO 1g0GNYEu7AXvzSVh0QqVWyYBFQHvsBTrOWhKGP5hjJajN3zQ5xL3IIFlFWBiu1mf hBYTqg0Ks9FDzGK2xL/TSBj+EXrTT0PlLFSEaV0ZlhHdzpYJVyfndmZBZBDC8JRK ZR3NM4XQnljwsYj/fSAKZDyByOuze768iyPciYoXnUw0k3axFI4DD/eDnGaicv6t VfZ2zLB3fisurzO0P1AFGySlZY2UZoHXwwg9Zdhuh5oxJWfiUfDqgmu0G40EbOZd 857pRDfULnS5L7fO5PzHmMudBe88w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrgedvgddvkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecuogfgmhhpthihtehlihgrshculdefledmnecujfgurh epfffhvffukfgjfhfogggtgfesthejredtjfdtvdenucfhrhhomhepfddfuceokhhfmhes phhluhhshhhkrghvrgdrnhgvtheqnecukfhppeduleefrddufeekrddvudekrdduledtne curfgrrhgrmhepmhgrihhlfhhrohhmpehkfhhmsehplhhushhhkhgrvhgrrdhnvghtnecu vehluhhsthgvrhfuihiivgeptd X-ME-Proxy: In-Reply-To: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-unknown-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.29 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20190709111616.26148014b42ea4210f634e1e@plushkava.net> X-Mailman-Original-References: <20190708092807.02edd68a60130b89a7775425@plushkava.net> Xref: csiph.com gnu.bash.bug:15094 Hi Mischa, On Tue, 09 Jul 2019 09:05:45 +0200 Mischa Baars wrote: > Hi Kerin, > > That indeed solves the problem in 'accesstime.sh', although I would recommend some sort of reference from the bash manpage to the mount manpage. > > 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. 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 That was with ext4 as the filesystem backing the TMPDIR. I also tested FreeBSD/UFS, with the same results, even if sleeping one second before updating the mtime. Perhaps Chet would be so kind as to clarify what's going on here. In the meantime, your technique of comparing the timestamps lexicographically seems like a good workaround, although you should use [[ instead. For example: # check() { local at=$(stat -c %x "$1") mt=$(stat -c %y "$1"); [[ $mt > $at ]]; } # f=$(mktemp); check "$f"; echo $?; touch -m "$f"; check "$f"; echo $? 1 0 -- Kerin Millar