Re: passing parameter to shell function as in the normal unix commands (not positional parameter)

From: Stephane CHAZELAS (this.address_at_is.invalid)
Date: 08/31/04


Date: 31 Aug 2004 13:20:42 GMT

2004-08-31, 13:11(+00), Robert Bonomi:
[...]
> while [ $# -ne 0 ]; do
>
> $# is _always_ defined, and has a strictly numeric value, with no embeded
> spaces or other 'funny business', to necessitate quoting.
>
> Well, unless one has _explicity_ set such a value into it, within the
> same script. In which case, you get what you *well* deserve. <grin>

I don't agree with that.

Word splitting is a feature you activate (ask for) when you
leave a variable unquoted (together with globbing).

$#, as I said, in perl, would be written map(glob,
split($IFS_regexp, $#)), which doesn't make sense in that
context. So, to my mind [ $# -gt 0 ] doesn't make sense either
(why one would like $# to get splitted and subject to filename
generation?).

So it's the one would doesn't quote variables, not the one who
resets IFS that is in trouble, and well deserves the script to
fail.

-- 
Stephane