xargs short-circuit

Matthew Story matthewstory at gmail.com
Tue Feb 14 19:37:18 UTC 2012


On Tue, Feb 14, 2012 at 2:35 PM, Jilles Tjoelker <jilles at stack.nl> wrote:

> On Tue, Feb 14, 2012 at 01:34:49PM -0500, Matthew Story wrote:
> > After reading the man-page, and browsing around the internet for a
> minute,
> > I was just wondering if there is an option in (any) xargs to
> short-circuit
> > on first failure of [utility [arguments]].
>
> > e.g.
>
> > $ jot - 1 10 | xargs -e -n1 sh -c 'echo "$*"; echo exit 1' worker ||
> echo $?
> > 1
> > 1
>
> > such that any non-0 exit code in a child process would cause xargs to
> stop
> > processing.  seems like this would be a nice feature to have.
>
> As per xargs(1), you can do this by having the command exit on a signal
> or with a value of 255.
>

Yes indeed it does ... should have scoured further, thanks!


>
> --
> Jilles Tjoelker
>



-- 
regards,
matt


More information about the freebsd-hackers mailing list