Interactive 2.2 File zapper.

Michael P. Lindner mpl at pegasus.ATT.COM
Fri Aug 3 02:20:59 AEST 1990


In article <2108 at cirrusl.UUCP> dhesi%cirrusl at oliveb.ATC.olivetti.com (Rahul Dhesi) writes:
	deleted
>The last time I looked, it was an undocumented feature in sh and csh
>(and probably in ksh though I didn't check) that a cd that failed would
>abort the rest of the script.  In fact, sh and csh (but not ksh) went a
	deleted
>--
>Rahul Dhesi <dhesi%cirrusl at oliveb.ATC.olivetti.com>
>UUCP:  oliveb!cirrusl!dhesi

I don't know of any undocumented feature wrt. "cd", but for safety's sake,
all my shell scripts start with the line

	set -e

which says "exit on error".  Anyplace where I expect a command to fail
but it's OK to go on, I put either

	# do something special if the command fails
	if command
	then
		:
	else
		echo >&2 "command failed -- exit code $?"
	fi

	# or

	# ignore the code - useful for those commands which
	# don't return a meaningful exit code
	command || :

	# or

	# ignore the failure - useful for things like
	mkdir -p $dir 2> /dev/null || :
	# or
	mv -f $files 2> /dev/null || :

Mike Lindner
AT&T Bell Labs
attmail!mplindner



More information about the Comp.unix.wizards mailing list