Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uwmcsd1!marque!uunet!mcvax!cernvax!ethz!iis!prl From: prl@iis.UUCP (Peter Lamb) Newsgroups: comp.unix.questions Subject: Re: shell &&, || constructs (really /bin/sh -e behaviour) Keywords: exit status Message-ID: <642@eiger.iis.UUCP> Date: 6 Oct 88 20:45:24 GMT References: <5651@sgistl.SGI.COM> <3741@boulder.Colorado.EDU> <703@necis.UUCP> <826@philmds.UUCP> <13810@mimsy.UUCP> <639@eiger.iis.UUCP> <831@philmds.UUCP> Reply-To: prl@iis.UUCP (Peter Lamb) Organization: Integrated Systems Lab., ETH Zuerich Lines: 48 In article <831@philmds.UUCP> leo@philmds.UUCP (Leo de Wit) writes: >In article <639@eiger.iis.UUCP> prl@iis.UUCP (Peter Lamb) writes: >|if you have a conditional, it is usually because you *EXPECT* the >|thing to fail sometimes, otherwise you wouldn't have bothered! > >Of course, but you must take two other things into account: >1) the conditional is not the exit status of a (1) command, but of a >command list. I can even write something down like: >if > >then > >fi >and put a whole shell script into the conditional clause (not that this >is common practice). Now do you want -e to be turned off for the whole >clause (see also beneath) ?? Yes. >A minimal change to the meaning of -e could add the functionality >required without hardly breaking existing code (i.e. the code that >already depends on shells that turn off -e for conditionals): >The last command of the conditional clause's command list should not >cause an exit if it fails and -e is set. This seems unnecessarily complicated. I would settle for *either* the BSD /bin/sh behaviour (always exit on -e) or for the SysV behaviour (don't exit if the return status of the list is `tested') provided a) It was always the same and b) It was clearly documented. What really bugs me about Ultrix is not so much the -e behavior as their totally crazy hacking of /etc/rc* and /etc/setld and other critical system scripts to put in their cutesy [ -f totally_nonstandard ] && { bizarre ; whacky } replacement of the standard `if' tests, so that I *can't* use the SysV shell (also provided by DEC in Ultrix as /bin/sh5) as /bin/sh because I won't be able to boot my machine multiuser any more! -- Peter Lamb uucp: seismo!mcvax!ethz!prl eunet: prl@ethz.uucp Tel: +411 256 5241 Institute for Integrated Systems ETH-Zentrum, 8092 Zurich