makefile bug workaround?
Paul Hite
paul at prcrs.UUCP
Sat May 27 05:47:47 AEST 1989
In article <153 at jma.UUCP>, max at jma.UUCP (Max Heffler @ Landmark Graphics) writes:
> all:
> if [ "" != "" ] ; then echo a ; else echo b ; fi
>
> I get an error code 1. But not if I change the != to =.
> Thanx in advance.
>
> P.S. I am using s5make with either /bin/sh or /bin/sh5, but I believe
> I had this problem with make also.
>
> Max Heffler uucp: ..!uunet!jma!max
You must be using /bin/sh. This is an older shell that doesn't handle
the -e option as well as it should. When "make" invokes a shell, it
uses the -e option to cause the shell to exit if an error occurs. The
problem with older shells is that they take -e too literally. Your code
fragment will invoke test (via the [ alias) and in this case, test returns
a "failed" exit status. If you switch to /bin/sh5 this won't happen:
Script started on Fri May 26 15:27:49 1989
<21> sh -ec '[ "" != "" ] || echo b'
<22> echo $status
1
<23> sh5 -ec '[ "" != "" ] || echo b'
b
<24> echo $status
0
<25> ^D
script done on Fri May 26 15:32:05 1989
As you can see the -e and flow control just don't mix with the old shell.
So one work-around is to switch to sh5 by putting a "SHELL=/bin/sh5" in your
makefile. (Be sure that you really are using s5make because make will not
use the SHELL macro to change shells.) This employs some of the System 5 stuff
that DEC has added to Ultrix. In a pure BSD environment, another work-around
is often used:
all:
-if [ "" != "" ] ; then echo a ; else echo b ; fi
^
| Note the minus sign
This tells "make" to ignore the exit code (i. e. don't use -e).
Hope this helps.
Paul Hite PRC Realty Systems McLean,Va uunet!prcrs!paul (703) 556-2243
DOS is a four letter word!
More information about the Comp.unix.ultrix
mailing list