cd failure killing script [Re: Interactive 2.2 File zapper]

Dan_Jacobson at ATT.COM Dan_Jacobson at ATT.COM
Fri Aug 3 12:26:41 AEST 1990


dhesi%cirrusl at oliveb.ATC.olivetti.com (Rahul Dhesi) writes:
>     cd /lost+found; find . -mtime +14 -exec rm -rf {} \;
>If the cd fails, no damage is done, because the rest of the line is not
>executed.  Any sensible shell ought to let at least this work, even if
>it doesn't abort the entire script.

Saying that there should be a special case just for the cd command, and
just for the rest of this line is ripping up the whole uniformity and
generality of the shell [/bin/sh family of shells assumed].  If you want
a failed cd to kill the script, then do "set -e" or "cd dir || exit 1".
For just missing the rest of the line: "cd dir && bla bla bla".

[I'm speaking from a general UNIX view, and don't even read the i386
newsgroup, Followup-To: comp.unix.wizards]
-- 
Dan_Jacobson at ATT.COM +1-708-979-6364



More information about the Comp.unix.i386 mailing list