bug-diffutils
[Top][All Lists]
Advanced

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

[bug-diffutils] bug#17075: bug#17075: bug#17075: diff - - exits immediat


From: Eric Blake
Subject: [bug-diffutils] bug#17075: bug#17075: bug#17075: diff - - exits immediately
Date: Mon, 24 Mar 2014 06:33:51 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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