[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [coreutils] basename/dirname can't handle stdin?
From: |
Eric Blake |
Subject: |
Re: [coreutils] basename/dirname can't handle stdin? |
Date: |
Wed, 12 Jan 2011 12:02:15 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7 |
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?
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [coreutils] basename/dirname can't handle stdin?, Jeff Blaine, 2011/01/12
- Re: [coreutils] basename/dirname can't handle stdin?,
Eric Blake <=
- Re: [coreutils] basename/dirname can't handle stdin?, Jeff Blaine, 2011/01/12
- Re: [coreutils] basename/dirname can't handle stdin?, Jeff Blaine, 2011/01/12
- Re: [coreutils] basename/dirname can't handle stdin?, Jim Meyering, 2011/01/13
- Re: [coreutils] basename/dirname can't handle stdin?, Jeff Blaine, 2011/01/13
- Re: [coreutils] basename/dirname can't handle stdin?, Philipp Thomas, 2011/01/13
- Re: [coreutils] basename/dirname can't handle stdin?, Jim Meyering, 2011/01/13
- Re: [coreutils] basename/dirname can't handle stdin?, Eric Blake, 2011/01/13
- Re: [coreutils] basename/dirname can't handle stdin?, Jim Meyering, 2011/01/13
- Re: [coreutils] basename/dirname can't handle stdin?, Eric Blake, 2011/01/13