Nasty little shell syntax problem for a Wizard
Frank Merrow
frank at odetics.com
Thu Nov 15 09:41:42 AEST 1990
I am pretty good at shell, but this one has me a little stumped:
I am running a command out of "make" so the condition code is important in what
I am doing . . .
Step 1
gcc <parms> || (abort_script;exit 1)
This statement lets me do some post processing when the compiler finds an error.
Step 2
gcc is generating a SINGLE warning message that I want to suppress, BUT I want
the warning in all cases except for one VERY special one. So what I want to
do is something like:
gcc <parms> 2>&1 | egrep -v "<re>"
This has problems because the condition code that make seems to use is the
one from the egrep NOT the gcc.
Problem:
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.
Note one possible solution I thought of was
gcc <parms> 2>&1 > temp_file || (abort_script;exit1)
egrep -v "<re>" temp_file
The problem with this solution is that on Error the errors do NOT appear on
stdout because the egrep doesn't get done.
Another solution is to actually put a compound "if" shell statement in the
makefile. My make does support this, but I personally think it looks
tacky and would prefer to avoid this solution.
Any shell wizards got a slick solution to this?
Frank
frank at odetics.com or uunet!odetics!frank
More information about the Comp.unix
mailing list