bug-findutils
[Top][All Lists]
Advanced

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

Re: Why xargs still call the command when there is no input?


From: Eric Blake
Subject: Re: Why xargs still call the command when there is no input?
Date: Tue, 02 Jun 2015 21:59:22 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

On 06/02/2015 04:02 PM, Peng Yu wrote:
> The following command will call ls. But since there is no input,
> shouldn't xargs quit without doing anything? Thanks.
> 
> xargs -0 ls </dev/null

Try:

xargs -r -0 ls </dev/null

Per POSIX, the behavior of one-or-more (without -r) is required, to
match historical practice, and existing scripts rely on that behavior.

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/xargs.html

We have the -r extension precisely because sometimes the zero-or-more
behavior makes more sense.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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