Path: utzoo!attcan!uunet!prcrs!paul From: paul@prcrs.UUCP (Paul Hite) Newsgroups: comp.unix.ultrix Subject: Re: makefile bug workaround? Keywords: sh or sh5 with s5make syntax bug Message-ID: <1447@prcrs.UUCP> Date: 26 May 89 19:47:47 GMT References: <153@jma.UUCP> Organization: PRC Realty Systems, McLean, VA Lines: 45 In article <153@jma.UUCP>, max@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!