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

From: Heiner Steven (heiner.steven_at_nexgo.de)
Date: 08/31/04


Date: Tue, 31 Aug 2004 15:45:16 +0200

Stephane CHAZELAS wrote:
> 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.

Could you post an example where

     while [ $# -ne 0 ]; do ...

would fail?

Heiner

-- 
  ___ _
/ __| |_ _____ _____ _ _     Heiner STEVEN <heiner.steven@nexgo.de>
\__ \  _/ -_) V / -_) ' \    Shell Script Programmers: visit
|___/\__\___|\_/\___|_||_|   http://www.shelldorado.com/


Relevant Pages