Subject: bug#7999: [coreutils-8.x] documentation of touch command needs clarification

From: Eric Blake <[email-masked]>
Date: Tue, 08 Feb 2011 08:22:31 -0700

On 02/07/2011 04:36 PM, Nelson H. F. Beebe wrote:
> If I want to guarantee identical timestamps, am I forced to use a
> temporary reference file, perhaps like this?
> 
> 	touch /tmp/TIMESTAMP.$$
> 	touch -r /tmp/TIMESTAMP.$$ first second ... umpteenth
> 	rm -f /tmp/TIMESTAMP.$$

Yes, if you want guaranteed equivalence in timestamps, you must use a
reference file.

On 02/07/2011 10:37 PM, Paul Eggert wrote:
> On 02/07/2011 03:36 PM, Nelson H. F. Beebe wrote:
>> Perhaps the coreutils manual page and info documentation could be
>> updated to document what that implementation does, and discuss whether
>> it agrees or differs from other implementations (and POSIX).
>
> If A and B both exist, then "touch A B" might set A's time stamp
> to be earlier than B's, or later than B's, or they might
> be set to exactly the same time.  POSIX doesn't say, and I suspect that
> for efficiency reasons coreutils's documentation shouldn't say
> either (except perhaps to say that it doesn't say :-).

Well, POSIX generally states that arguments are process left-to-right,
so A should be processed before B.  However, depending on whether time
was cached when touch first started, or updated for each file touched,
affects whether A < B or A == B.  Then there's the matter of multiple
mount points, where different precision between mount points (or even
differing NFS clocks) can indeed lead to B > A, without any loss of
generality (since POSIX is silent on the matter of intra-file relations
within a single touch invocation).

-- 
Eric Blake   [email-masked]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org