Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!ukc!its63b!simon From: simon@its63b.ed.ac.uk (Simon Brown) Newsgroups: comp.unix.questions Subject: Re: Recovery scripts: use $@ Message-ID: <506@its63b.ed.ac.uk> Date: Sat, 27-Jun-87 11:23:40 EDT Article-I.D.: its63b.506 Posted: Sat Jun 27 11:23:40 1987 Date-Received: Sat, 4-Jul-87 17:42:38 EDT References: <913@rtech.UUCP> <7062@mimsy.UUCP> <767@bsu-cs.UUCP> <1500@ho95e.ATT.COM> <1444@hou2d.UUCP> Reply-To: simon@its63b.ed.ac.uk (Simon Brown) Organization: Computer Science Department, Edinburgh University Lines: 38 Keywords: #!, csh, ksh In article <1444@hou2d.UUCP> avr@hou2d.UUCP (Adam V. Reed) writes: >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 >> >> 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) This will not work for a "sh -c command" type thing - the ``command'' must be a single word, and "$@" splits up into lots of separate words - so, better would be to use ksh "$0" "$@" instead. In fact, Use ${1+"$@"} instead of "$@", because the latter gets it wrong if there are no positional parameters set (it subsitutes the empty string instead of nothing at all). I believe ksh has this ``fixed''. %{ Simon! %} -- ---------------------------------- | Simon Brown | UUCP: seismo!mcvax!ukc!its63b!simon | Department of Computer Science | JANET: simon@uk.ac.ed.its63b | University of Edinburgh, | ARPA: simon%its63b.ed.ac.uk@cs.ucl.ac.uk | Scotland, UK. | ---------------------------------- "Life's like that, you know"