Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!ukc!stl!stc!root44!andrew From: andrew@root.co.uk (Andrew Dingwall) Newsgroups: comp.unix.questions Subject: Re: Forcing /bin/sh in a script under V/386 3.2 Korn shell Message-ID: <776@root44.co.uk> Date: 31 Jul 89 17:15:57 GMT References: <2318@wyse.wyse.com> <799@jonlab.UUCP> Reply-To: andrew@root44.UUCP (Andrew Dingwall) Organization: UniSoft Ltd, London, England Lines: 32 In article <799@jonlab.UUCP> jon@jonlab.UUCP (Jon H. LaBadie) writes: ... Much deleted ... >Combining these comments and using the conditional operator rather than >an if statement; plus quoting $0 on general principles, we have: > > [ "${RANDOM}" = "${RANDOM}" ] || exec /bin/sh -c "${0}" ${@:+"${@}"} > Careful, when you use sh -c "string ...", arguments after the string are assigned to positional parameters starting with $0 - not $1 as one might expect. for example, try this: $ /bin/sh -c 'echo $@' a b c d b c d $ /bin/sh -c 'echo $0 $@' a b c d a b c d (this happens on System V (at least)).