GNU bug report logs -
#17075
diff - - exits immediately
Previous Next
Reported by: karl <at> freefriends.org (Karl Berry)
Date: Sun, 23 Mar 2014 21:22:02 UTC
Severity: normal
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 17075 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 03/23/2014 03:47 PM, Paul Eggert wrote:
> Karl Berry wrote:
>> It seems like it should either read stdin twice (probably too much
>> trouble), or read stdin once and then abort when it can't be read again,
>> or just abort immediately. Or something, just not success.
>
> I don't see why 'diff' should be prohibited from optimizing the case
> 'diff A A'. 'diff' should be allowed to read 'A' just once (or even not
> at all, which is what 'diff' actually does). '-' is just a special case
> of this.
POSIX states in XCU 1.4:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html
Unless otherwise stated, the use of multiple instances of '-' to mean
standard input in a single command produces unspecified results.
and its description for 'diff' does not place any other requirements on
double '-', so we are free to behave however we want. I personally
think that special-casing '-' to read stdin twice makes more sense, at
least when fstat(0) says that stdin is not a regular file (the way that
'cat - -' behaves differently for stdin used twice). I agree with the
optimization of not reading a file at all if we know the argument is not
'-', or if the argument is '-' but fstat(0) says the file is regular.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 11 years and 107 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.