What's the return status of a pipeline???

Chris Torek chris at mimsy.UUCP
Thu May 11 21:25:47 AEST 1989


(The exit status of a pipeline is supposed to be the exit status of the
last process in the pipeline.  4BSD sh does not always get this right.)

In article <186 at marvin.moncam.co.uk> harry at moncam.co.uk
(Jangling Neck Nipper) writes:
[csh script; all but the important part deleted]
>onintr quit
>$BIN/psfilter -b $* | $BIN/lwriter -pI "$LWRITER" $* >>& $acct
>quit:
>set printer_status = $status

This will always set printer_status to 0.  Let us hear it for csh
`design':  the label `quit' succeeds, wiping out the exit status
from the pipeline above.

See:

	% (exit 1)
	% echo $status
	1
	% (exit 1)
	% foo:
	% echo $status
	0
	%

Moral: never try to use csh for shell scripts.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list