shell &&, || constructs (really /bin/sh -e behaviour)

Peter Lamb prl at iis.UUCP
Fri Oct 7 06:45:24 AEST 1988


In article <831 at philmds.UUCP> leo at philmds.UUCP (Leo de Wit) writes:
>In article <639 at eiger.iis.UUCP> prl at 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 
><shell script here>
>then
><other stuff here>
>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 at ethz.uucp	Tel:   +411 256 5241
Institute for Integrated Systems
ETH-Zentrum, 8092 Zurich



More information about the Comp.unix.questions mailing list