Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!watmath!clyde!ima!haddock!karl
From: karl@haddock.UUCP
Newsgroups: comp.unix.questions
Subject: Re: $@ vs. $* (was - Re: nohup (from Bourne shell))
Message-ID: <198@haddock.UUCP>
Date: Fri, 12-Dec-86 20:59:50 EST
Article-I.D.: haddock.198
Posted: Fri Dec 12 20:59:50 1986
Date-Received: Mon, 15-Dec-86 20:41:28 EST
References: <181@haddock.UUCP> <106@quacky.UUCP> <164@its63b.ed.ac.uk>
Reply-To: karl@haddock.ISC.COM.UUCP (Karl Heuer)
Distribution: world
Organization: Interactive Systems, Boston
Lines: 24
Keywords: sh, positional parameters

In article <164@its63b.ed.ac.uk> simon@its63b.ed.ac.uk (ECSC68 S Brown CS) writes:
>In article <106@quacky.UUCP> dce@quacky.UUCP (David Elliott) writes:
>>Anyway, the following statement can be used to fix [the $@ bug] ...
>
>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.

Shell scripts are already non-portable across versions of UNIX.  The three
major branches (Research, USG, and Berkeley) have distinct versions of echo!
Hopefully the $@ fix will be applied to an entire branch rather than being
done individually at each installation.  (I presume nobody *depends* on this
bug...)  Research V8 has already applied the fix, I believe.

>So, until [it] is official, its probably better just to be very careful...
>One foolproof way is to always use ${1+"$@"} in place of $* or $@ or "$@"...

Hey!  That's not bad!  I've been using crap like
	if [ $# = 0 ]; then cmd; else cmd "$@"; fi
which is uglier -- if your notation really works (it should, but I'm going to
run some tests before I rewrite things) I'll convert my shell scripts.

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint
Btw, the V8 echo is the best of the lot; I hope the others adopt it.