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 17:09:11 -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

Eric, now that I've got the prereqs in place,
built coreutils from git successfully, and read the
coreutils HACKING file, let's make sure I am on your
page:

In no order:

* Snarf getopt_long arg processing from wc.c or other
  you mentioned
* Add --filter (combined with the lack of file args) to handle
  processing of stdin
* Add --files-from0 per wc.c code (found it there)
* Add --suffix [suffix] to enable suffix killing (using
  SUFFIX as the 2nd arg will no longer work going forward)
* Update usage() obviously

Correct?  Anything else?

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]