[Top][All Lists]

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

Re: basename BSD compatibility and filter mode

From: Pádraig Brady
Subject: Re: basename BSD compatibility and filter mode
Date: Mon, 05 Mar 2012 09:35:04 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

On 03/05/2012 09:07 AM, Bernhard Voelker wrote:
> On 03/03/2012 10:00 PM, Pádraig Brady wrote:
>> Yes, I agreed with Eric that -0 was useful,
> If basename is used as a filter in the middle of pipe,
> then I think it maybe would make sense to have a 0-option
> for the output:
> find . -type f -print0 \
>   | xargs -0 -r0 basename --out-null \
>   | xargs -0 -r0 do_something_else
> What do you think?

Grr, yes to support file names containing '\n'.
Now that's uncommon, and could be supported as follows:

tr '\n' '\1' |
xargs -0 -r0 basename
tr '\1\n' '\n\0' |

However the above is awkward and assumes you can pick a char
that is guaranteed not to appear in a file name
('\1' in the above example).

Now the recent `realpath` added this option for precisely this reason
(and for compat with the existing debian util):

  -z, --zero   separate output with NUL rather than newline

Reading back on Eric's argument and my ack to that, I think
Eric was alluding to output rather than input, and he
also mentioned -z.  So I'm leaning towards adding that to
basename (and dirname) too.


reply via email to

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