From owner-freebsd-questions Mon May 5 02:53:42 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id CAA15556 for questions-outgoing; Mon, 5 May 1997 02:53:42 -0700 (PDT) Received: from mail.EUnet.hu (www.eunet.hu [193.225.28.100]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id CAA15541 for ; Mon, 5 May 1997 02:53:32 -0700 (PDT) Received: by mail.EUnet.hu, id LAA02551; Mon, 5 May 1997 11:53:23 +0200 Received: (from zgabor@localhost) by CoDe.hu (8.7.5/8.7.3) id KAA00481; Mon, 5 May 1997 10:13:28 +0200 (MET DST) From: Zahemszky Gabor Message-Id: <199705050813.KAA00481@CoDe.hu> Subject: Re: sh - lists, pipes & exits To: freebsd-questions@freebsd.org (FreeBSD questions) Date: Mon, 5 May 1997 10:13:27 +0200 (MET DST) Cc: un_x@anchorage.net In-Reply-To: from Steve Howe at "Apr 29, 97 03:37:41 am" X-Mailer: ELM [version 2.4ME+ PL11 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > how can i return an exit value (to the invokers shell) of a command in a > list which gets piped into "more" ... > > { gcc 2>&1 see.c; xit=$?; if [ $xit ]; then exit $xit; fi; } | more > ------------------------------------------------------------------------- > of course, "xit" ends up getting "wiped", and more is executed regardless. > i can't figure out how to do this without executing gcc 2x ... > such as follows ... > ------------------------------------------------------------------------- > gcc 1>&- 2>&- see.c; xit=$? > if [ $xit != 0 ]; then blah; blah; exit $xit > else gcc 2>&1 see.c | more > fi > > 1) $ { gcc see.c ; echo $? > /tmp/compiler.out.$$ ; } | more ; xit=`cat /tmp/compiler.out.$$ ; rm -f /tmp/compiler.out.$$` 2) Look around in ksh's (zsh/bash cannot do it!) coprocesses and the wait command (well, I tried it, but couldn't find a quick answer). Gabor