[Top][All Lists]

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

Re: [PATCH] ls: adding --zero/-z option, including tests

From: Pádraig Brady
Subject: Re: [PATCH] ls: adding --zero/-z option, including tests
Date: Mon, 03 Feb 2014 15:27:31 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 02/03/2014 03:15 PM, Anthon van der Neut wrote:
> |
> A recent Q&A thread on on the reason why ls has no 
> option
> like find to generate NUL separated output triggered the making of this patch.
> ( ).
> Quite often questions pop up on that site where questioners, unaware of the
> fact that newlines and other special characters can be part of filenames do
> something like:
>     ls -rt | xargs ...
> Invariably someone points out that it is not safe to process the output of ls 
> in
> this way in general.
> The included patch adds an option --zero/-z to ls so that the filenames
> are separated by the NUL character instead of a newline when doing the -1
> (which is in principle indistinguishable from a newline that is part of the
> filename as you can have "abc", "def" and "abc\ndef" as filenames in one
> directory).
> The patch allows one to do:
>     ls -rt --zero | xargs -0 ...
> and
> |||     ls -rtz | xargs -0 ...
> |
> One file with basic tests has been added, another extended.
> Please let me know if this is not acceptable, or if changes are
> required before this can be processed.

Thanks a lot for the patch.
If we were to do this then this is the interface we would use.
However ls is really a tool for direct consumption by a human,
and in that case further processing is less useful.
For futher processing, find(1) is more suited.
That is well described in the first answer at the link above.

So I'd be 70:30 against adding this.


reply via email to

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