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 (ECSC68 S Brown CS) Newsgroups: comp.bugs.4bsd,comp.unix.questions Subject: $@ vs. $* (was - Re: nohup (from Bourne shell)) Message-ID: <164@its63b.ed.ac.uk> Date: Sun, 7-Dec-86 10:36:52 EST Article-I.D.: its63b.164 Posted: Sun Dec 7 10:36:52 1986 Date-Received: Mon, 8-Dec-86 02:10:31 EST References: <181@haddock.UUCP> <106@quacky.UUCP> Reply-To: simon@its63b.ed.ac.uk (ECSC68 S Brown CS) Followup-To: comp.unix.questions Distribution: world Organization: I.T. School, Univ. of Edinburgh, U.K. Lines: 34 Keywords: sh, positional parameters Xref: mnetor comp.bugs.4bsd:65 comp.unix.questions:279 In article <106@quacky.UUCP> dce@quacky.UUCP (David Elliott) writes: > >There is one slight problem with "$@", which can be shown by the following > > [... example of the wll-known "feature" ...] > >Anyway, the following statement can be used to fix this bug in most >versions of sh. > > if (strcmp (as, "\"$@\"") == 0 && dolc == 0) { > return(fixstak()); > } > >Add these to the beginning of the subroutine macro() in macro.c, and the >bug goes away. It is somewhat kludgy, but it works. > However, if you fix this in your version of sh, it makes any shell-scripts that you may write assuming the "fixed" behaviour inherently non-portable, 'cos they'll immediately bomb out on standard shells. So, until the fix described above (or some equivalent thereof) is official, its probably better just to be very careful when using $* or $@ in scripts. One foolproof way is to always use ${1+"$@"} in place of $* or $@ or "$@" - ok, its ugly, I know... :-) -- Simon Brown Department of Computer Science, University of Edinburgh, Scotland. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Life's distressing - that's no blessing". [Anon.] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~