From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 14 19:35:32 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A8D401065670 for ; Tue, 14 Feb 2012 19:35:32 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id 452C88FC19 for ; Tue, 14 Feb 2012 19:35:32 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 3D86935AD5E; Tue, 14 Feb 2012 20:35:31 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 19A7328468; Tue, 14 Feb 2012 20:35:31 +0100 (CET) Date: Tue, 14 Feb 2012 20:35:31 +0100 From: Jilles Tjoelker To: Matthew Story Message-ID: <20120214193530.GA42580@stack.nl> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-hackers@freebsd.org Subject: Re: xargs short-circuit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Feb 2012 19:35:32 -0000 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. -- Jilles Tjoelker