is 'if' possible in /bin/sh when option -e is set ?

Chris Torek chris at mimsy.umd.edu
Wed Feb 21 00:57:16 AEST 1990


In article <2903 at sbsvax.cs.uni-sb.de> weinelt at sbsvax.cs.uni-sb.de
(Bernhard Weinelt) writes:
>if I set the option -e  (stop execution if a command fails) I
>can't use any if's ....

You have a copy of the Buggy Bourne Shell (tm), as distributed with
4.2 and 4.3 BSD and probably several other systems.  It can be identified
by running

	$ set -e
	$ if false; then echo gak; else echo ok; fi

and noting that the shell exits instead of printing `ok', and by

	$ set -e
	$ false || echo ok

which also exits (and should not), and by

	$ set -e
	$ while false; do :; done

To fix it, (1) get the source (2) change it in the obvious 3 places in
xec.c.  You will have to learn Bournegol.  Another alternative is to
replace /bin/sh with one of the free sh lookalikes, provided you can
find one that is enough alike.

As a work-around, you can `set +e' around all the tests that might fail.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list