On 4/22/06, Axel Liljencrantz <[EMAIL PROTECTED]> wrote:
If you find any places where $@ is easier/better, and not just
slightly different, please let me know, and we'll try to figure out
how to improve the fish syntax.

$@ only differs from $* when you expand in double quotes: "$@".
$* (and $@) is just broken - is expands into many words, splitting
args that contain spaces!
"$*" expands all args as one space-separated word.
Not very useful but "$argv" does that in fish.
"$@" does the right thing and expands every arg as one word.
$argv does that in fish.  "[EMAIL PROTECTED]" (yikes!) does that in bash
for other array variables.

Historic rationale:
Bourne shell didn't have array variables.  Therefore to simulate
arrays one would use a variable with spaces.  That's the reason that
$var expands to many words breaking on spaces.  This makes many
scripts that aren't careful to use "$var" break on filenames with
spaces - sometimes just annoying and sometimes a security problem :-(
But $* was an array variable (one of its kind), so they came up with
an ugly fix for this variable only, which became uglier when bash
generalized it.
fish has array variables from the beginning, so $var can default to a
1:1 expansion.  Haleluya.

BTW, while breaking on spaces is not useful for $*, it might be useful
for other vars.  How *does* one break vars on spaces?  The best I came
up with currently is:
set array_var (echo $space_separated_var | tr -s ' ' \n)
The main document mentions 'tokenize' which is suppozed to be a
external(?) command bundled with fish - but doesn't exist?

--
Beni Cherniavsky <[EMAIL PROTECTED]>, who can only read email on weekends.
Governments are like kernels - everything possible should be done in user space.

Reply via email to