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


Groups > gnu.bash.bug > #15094

Re: file access time and file modification time

Path csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From "" <kfm@plushkava.net>
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 <mailman.583.1562667389.2688.bug-bash@gnu.org> (permalink)
References <20190708092807.02edd68a60130b89a7775425@plushkava.net> <c7525b0b-937c-48e3-92f6-c5e5734b0426@email.android.com> <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 <mjbaars1977.bug-bash@cyberfiber.eu>
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 <xms:cmkkXaOcaJ0bFDXQ2AST7U1AsL19sYpNJQtphioQD0jqq9py1icQGA>
X-ME-Proxy-Cause gggruggvucftvghtrhhoucdtuddrgeduvddrgedvgddvkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecuogfgmhhpthihtehlihgrshculdefledmnecujfgurh epfffhvffukfgjfhfogggtgfesthejredtjfdtvdenucfhrhhomhepfddfuceokhhfmhes phhluhhshhhkrghvrgdrnhgvtheqnecukfhppeduleefrddufeekrddvudekrdduledtne curfgrrhgrmhepmhgrihhlfhhrohhmpehkfhhmsehplhhushhhkhgrvhgrrdhnvghtnecu vehluhhsthgvrhfuihiivgeptd
X-ME-Proxy <xmx:cmkkXeU2dEpIWv-7gll7YkPySvRk1UtDxOWSVYSZ7Y5Jb6NnCgh8AQ> <xmx:cmkkXRcEFmlhgboR_hGGmNK4DvlWnzF5IeAB4tqrCvWs4W8zcjILDw> <xmx:cmkkXav6UuDl_dColbixkSbMHLVUh4-mBsfFUzx-bl9d_lRrZny24g> <xmx:cmkkXS627REZu6Oy2lj_vLaPVNEJZjNCjLzqtue0oIUMKidWUjOxHw>
In-Reply-To <c7525b0b-937c-48e3-92f6-c5e5734b0426@email.android.com>
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 <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <20190709111616.26148014b42ea4210f634e1e@plushkava.net>
X-Mailman-Original-References <20190708092807.02edd68a60130b89a7775425@plushkava.net> <c7525b0b-937c-48e3-92f6-c5e5734b0426@email.android.com>
Xref csiph.com gnu.bash.bug:15094

Show key headers only | View raw


Hi Mischa,

On Tue, 09 Jul 2019 09:05:45 +0200
Mischa Baars <mjbaars1977.bug-bash@cyberfiber.eu> 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 <kfm@plushkava.net>

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: file access time and file modification time "" <kfm@plushkava.net> - 2019-07-09 11:16 +0100

csiph-web