bug-coreutils
[Top][All Lists]
Advanced

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

bug#25388: Bug in ls, kills existing scripts reading "ls" -1 as input


From: Eric Blake
Subject: bug#25388: Bug in ls, kills existing scripts reading "ls" -1 as input
Date: Mon, 9 Jan 2017 14:50:53 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0

On 01/09/2017 02:35 PM, L A Walsh wrote:
>     I also stand for it being strongly against GNU
> standards to add more such behaviors.

'ls' did not recently add any more cases where tty output differs from
non-tty output when all other things are equal in the default state.
All that changed was that tty output is formatted differently than it
has been in the past.  And, as always, if you don't like the default,
you can override it.

> 
>> As the premise for this argument was incorrect, it
>> shouldn't be surprising if readers disagree with its conclusion.
> ----
>     Now you are deliberately excluding the fact.  While my
> initial stance was that it was engaging in non-standard behavior
> (which is true)

No, your claim that ls' behavior is non-standard has been proven to be
false; I quoted the line from POSIX that explicitly permits ls to use
implementation-defined behavior when outputting to a terminal, and if it
is permitted by the standard, then the behavior can't be considered
non-standard.  It may not be what you want, but that does not make it
non-standard.

> -- it is also the case that an exception was
> made for 'ls' for historical behavior.
> 
>     This is not historical behavior.  'ls' doesn't get
> a carte blanc to change output anyway it wants because of a specific
> historical behavior. 

Now you are excluding a fact.  POSIX _does_ state that the output of
'ls' when targetting a tty is implementation-defined, so we _do_ get
carte blanche permission to define our implementation to do what we
think is the sanest default, even if our definition of sanest changes
over time as we gain more experience on what types of problems trip up
the most default users.  The fact that ls output to a tty differs from
what you get when outputting to a pipeline or file is irrelevant - ls
output to a tty has ALWAYS differed from pipeline and file, when relying
on the defaults.  And if you don't LIKE the difference, then don't use
the defaults - write your alias to override the defaults to ask
explicitly for a format that does not add quoting you don't like.

And remember, scripts are UNLIKELY to be broken by the recent change in
what gets output to a tty, because scripts don't usually direct 'ls'
output to a tty, at least not if that output is going to affect the
control flow of the script (as it is, scripts that try to parse 'ls'
output are generally already broken; there are much better tools for
handling directory contents than trying to parse 'ls' output).

-- 
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]