Nasty little shell syntax problem for a Wizard
Jan Newmarch
jan at golf.canberra.edu.au
Wed Nov 21 11:03:20 AEST 1990
>Conceptually what I want is something like:
>gcc <parms> 2>&1 | egrep -v "<re>" || (abort_script;exit 1)
>Except that I want the || to use the condition code from the gcc (NOT the egrep)
>AND I want the condition code of the whole expression to be OK if the compile
>is OK or ERROR if the compile has an error.
The shell variable `?' holds the exit code of the last instruction executed,
so you could run your gcc, save the exit code, run egrep and the exit:
gcc > ...
code=$?
egrep ...
exit $code
+----------------------+---+
Jan Newmarch, Information Science and Engineering,
University of Canberra, PO Box 1, Belconnen, Act 2616
Australia. Tel: (Aust) 6-2522422. Fax: (Aust) 6-2522999
ACSnet: jan at ise.canberra.edu.au
ARPA: jan%ise.canberra.edu.au at uunet.uu.net
UUCP: {uunet,ukc}!munnari!ise.canberra.edu.au!jan
JANET: jan%au.edu.canberra.ise at EAN-RELAY
+--------------------------+
More information about the Comp.unix
mailing list