[ale] Partial interpretation in a bash script

Danny Cox danscox at mindspring.com
Mon Oct 27 17:40:45 EST 2003


Geoffrey,

On Mon, 2003-10-27 at 06:07, Geoffrey wrote:
> I seem to remember there was a difference in $@ and $* from my early 
> shell days, but couldn't put my finger on it.  I couldn't find a 
> reference to it.  I dug up my old ksh book and did in fact find that 
> there is a difference, although that difference is not emulated in pdksh.

	Typically, you always want to use "$@" in shell scripts.  The
difference is:

	"$*" expands to one argument with the positional parameters seperated
with the 1st char of $IFS.  Like: "$1 $2 $3 ...".

	"$@" expands to multiple arguments, each quoted.  As if you had said,
"$1" "$2" "$3" ....

	If that's not enough quoting for you, you can always use Perl, which
has a function (or syntax) for quoting special characters.  I'll leave
it to the Perl gurus to expound on that.

	And as Groucho said, "Two more quotes and we'd have a gallon!"

-- 
kernel, n.: A part of an operating system that preserves the
medieval traditions of sorcery and black art.

Danny



More information about the Ale mailing list