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: Stephane Chazelas
Subject: Re: Why xargs still call the command when there is no input?
Date: Wed, 17 Jun 2015 11:42:01 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

2015-06-02 21:59:22 -0600, Eric Blake:
> 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.
[...]

I would expect there be a lot more scripts that are broken by
that than there are that rely on it.

Note that FreeBSD and NetBSD xargs don't run any command if the
input is blank. They also support -r for compatibility with GNU
xargs, though that's just ignored there since -r is the default
behaviour.

OpenBSD still runs one command and supports -r.

(according to manuals at http://www.freebsd.org/cgi/man.cgi)

-- 
Stephane




reply via email to

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