Date: Mon, 5 May 1997 10:13:27 +0200 (MET DST) From: Zahemszky Gabor <zgabor@CoDe.hu> To: freebsd-questions@freebsd.org (FreeBSD questions) Cc: un_x@anchorage.net Subject: Re: sh - lists, pipes & exits Message-ID: <199705050813.KAA00481@CoDe.hu> In-Reply-To: <Pine.BSF.3.95q.970429032611.8526A-100000@aak.anchorage.net> from Steve Howe at "Apr 29, 97 03:37:41 am"
next in thread | previous in thread | raw e-mail | index | archive | help
> > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705050813.KAA00481>