🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix
Article #313

Nasty little shell syntax problem for a Wizard

#313
From: Frank Merrow
Date: Wed, 14 Nov 1990 22:41
48 lines
1995 bytes
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@odetics.com or uunet!odetics!frank
Technical Details
Message-ID: <2258@megadon.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!apple!altos!megadon!clp

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!apple!altos!megadon!clp
From: frank@odetics.com (Frank Merrow)
Newsgroups: comp.unix
Subject: Nasty little shell syntax problem for a Wizard
Message-ID: <2258@megadon.UUCP>
Date: 14 Nov 90 22:41:42 GMT
Sender: clp@megadon.UUCP
Reply-To: uunet!odetics!frank (Frank Merrow)
Organization: Odetics, Inc., Anaheim, CA
Lines: 48
Approved: clp@megadon.UUCP
Apparently-To: uunet!comp-unix