From owner-freebsd-hackers@FreeBSD.ORG Sat Jun 23 17:14:11 2012 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 972C5106566B for ; Sat, 23 Jun 2012 17:14:11 +0000 (UTC) (envelope-from johans@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id 2812E8FC0C for ; Sat, 23 Jun 2012 17:14:11 +0000 (UTC) Received: by mx1.stack.nl (Postfix, from userid 65534) id 1D9D81DD5BC; Sat, 23 Jun 2012 19:14:09 +0200 (CEST) X-Spam-DCC: wuwien: scanner01.stack.nl 1290; Body=1 Fuz1=1 Fuz2=1 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on scanner01.stack.nl X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.2.5 X-Spam-Relay-Country: _RELAYCOUNTRY_ Received: from mud.stack.nl (mud.stack.nl [131.155.141.70]) by mx1.stack.nl (Postfix) with ESMTP id 43E3A1DD5AD; Sat, 23 Jun 2012 19:14:07 +0200 (CEST) Received: by mud.stack.nl (Postfix, from userid 801) id 3B94C96537; Sat, 23 Jun 2012 19:14:07 +0200 (CEST) Date: Sat, 23 Jun 2012 19:14:07 +0200 From: Johan van Selst To: rank1seeker@gmail.com Message-ID: <20120623171407.GA32232@mud.stack.nl> References: <20120622.192538.734.2@DOMY-PC> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="AhhlLboLdkugWU4S" Content-Disposition: inline In-Reply-To: <20120622.192538.734.2@DOMY-PC> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: hackers@freebsd.org Subject: Re: tcsh's exit codes 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: Sat, 23 Jun 2012 17:14:11 -0000 --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: inline rank1seeker@gmail.com wrote: > There is something wrong with tcsh shell: > > # mergemaster -V | grep '\--run-updates' > Returned exit code 1 > # mergemaster -V | grep -q '\--run-updates' > Returned exit code 141 I believe this has been a feature of csh and tcsh since the dark ages. Negative status codes propagate through pipelines (and through backtick sub-commands as well). In fact the returned $status value is the value of the last command that returned an error (non-zero) status code. This makes it easy to determine if a pipeline command sequence has failed. The 141 status code indicates a sigpipe: the pipeline was not completely read (as described in the grep manual for this case). This also is the common exit code when using head(1) for example. This error-propagation behaviour can be suppessed with 'unset anyerror' in tcsh. In that case it should work as you expect. But note that your commands are no longer compatible with 'good old' csh behaviour then. Regards, Johan --AhhlLboLdkugWU4S Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- iF4EAREIAAYFAk/l+V4ACgkQAEpMHW8nCPTzagD/YrtplIISlVDTgfVjxCpVeS1s 7oK6OJ5+AoIfx09ra8sA/iGXuJEuhRx2LTZQFfIEwch1foGDiOIqzW64fII/ZENg =Dliq -----END PGP SIGNATURE----- --AhhlLboLdkugWU4S--