[comp.unix.shell] sh differences: v7 vs. SVr2

mcgrew@ichthous.Eng.Sun.COM (Darin McGrew) (01/04/91)

In article <2577@wn1.sci.kun.nl> hansm@cs.kun.nl (Hans Mulder) writes:
>Both the v7 and the SVR2 sh manuals mention that
>"the exit status of a pipeline is the exit status of the last command".
>
>The problem is the the word "last" is ambiguous.
>
>The v7 sh takes it to mean "last to terminate", SVR2 interprets it as
>"rightmost".

An interesting glitch I ran into with a sh from a BSD port
(running SunOS 4.1, it works as expected).  The script

	(sleep 5; false)&
	if (sleep 10)
	then echo true
	else echo false
	fi

would echo "false" because the exit status from the backgrounded
subshell would clobber the exit status of other subshell.  This
caused all manner of havoc in a script that forked several
background shells, and figuring out what was going wrong was a
lot of fun.

Darin McGrew			mcgrew@Eng.Sun.COM
Affiliation stated for identification purposes only.