coreutils
[Top][All Lists]
Advanced

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

Re: [coreutils] basename/dirname can't handle stdin?


From: Jeff Blaine
Subject: Re: [coreutils] basename/dirname can't handle stdin?
Date: Wed, 12 Jan 2011 14:03:49 -0500
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7

Sure, I can try at least!

On 1/12/2011 2:02 PM, Eric Blake wrote:
On 01/12/2011 11:43 AM, Jeff Blaine wrote:
I was surprised to find this today.

The following fails:

     echo /some/place/foo.txt | basename

This also fails:

     find /somewhere -print | xargs basename

This *does* work though, somehow, when the above does not:

     echo /some/place/foo.txt | xargs basename

What is going on here?  dirname is the same way.

POSIX requires that basename and dirname be passed arguments; they are
not required to run as filters.

That said, it would be awesome if someone would contribute the patches
to emulate the BSD extensions of:

      basename [-a] [-s suffix] string [...]

 From there, it's not much harder to implement extensions that 0
arguments is an extension to operate in filter mode (although we may
want to require the use of basename --filter to make it obvious, and we
would certainly want basename --files-from0 to operate on find -print0
output).

But someone has to contribute the patch - are you willing?




reply via email to

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