On 4/23/06, Beni Cherniavsky <[EMAIL PROTECTED]> wrote: > 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.
There is a reason why no one uses bash arrays. > > 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. Does seem a lot better, doesn't it? > > 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? The documentation still mentions tokenize? I'll fix it, 'tokenize' was dropped since the 'tr' does the same thing better. I think I added it with some vauge idea of providing commands that performed common array operations, but it wasn't really a good idea. But yes, the above substitution is how to separate on spaces in fish, and I think it's a good way to do it - separating on spaces is a strange thing to do, so I'm fine with it being a bit wordy in exchange for a readable, logical code. The important thing is that sane things, like _not_ separating on spaces is terse. > > -- > Beni Cherniavsky <[EMAIL PROTECTED]>, who can only read email on weekends. > Governments are like kernels - everything possible should be done in user > space. > -- Axel ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642 _______________________________________________ Fish-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/fish-users
