Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!homxb!houxm!hou2d!avr From: avr@hou2d.UUCP Newsgroups: comp.unix.questions Subject: Recovery scripts: use $@ Message-ID: <1444@hou2d.UUCP> Date: Tue, 23-Jun-87 22:32:23 EDT Article-I.D.: hou2d.1444 Posted: Tue Jun 23 22:32:23 1987 Date-Received: Fri, 26-Jun-87 02:06:32 EDT References: <913@rtech.UUCP> <7062@mimsy.UUCP> <767@bsu-cs.UUCP> <1500@ho95e.ATT.COM> Organization: AT&T Bell Laboratories, Holmdel Lines: 19 Keywords: #!, csh, ksh Summary: use $@ rather than $* In article <1500@ho95e.ATT.COM>, wcs@ho95e.ATT.COM (Bill.Stewart) writes: > I generally write all my scripts in Bourne Shell, because I know they'll work > (relatively) portably. When it's important to use ksh, I use the following: > if [ "$RANDOM" = "$RANDOM" ] > then ## recovery script to feed itself to ksh > ksh -c "$0 $*" > exit "$?" > fi > > The simpler approach of checking $SHELL doesn't work; SHELL is exported, > and some programs will drop into /bin/sh by default. ksh updates $RANDOM each > time it uses the value, so "$RANDOM" = "$RANDOM" will never be true in ksh, > and will (presumably) always be true in other shells. > > Writing a good recovery script is hard; if the arguments to the program > contain white space or metacharacters, the $* will trash them. Use $@ instead of $*. Adam Reed (hou2d!avr)