Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Docs fix



Bart Schaefer wrote:
> 
> On Oct 26,  7:25pm, Zoltan Hidvegi wrote:
>> Subject: Re: Docs fix
>>> > The first one is just some stuff for the FAQ about $* vs "$@"
>>> 
>>> The FAQ was correct without this patch.  $* and "$@" are equivalent in
>>> zsh, unless you run it under Bourne sh or ksh emulation (i.e. with the
>>> SH_WORD_SPLIT option set).
>> 
>> Not exactly.  "$@" keeps empty arguments and independent of option and
>> IFS settings, neither of which is true for $*.
> 
> Yes, but as I was just explaining privately to Phil, the context of his
> change is "what zsh construct is most like using \!* in csh aliases?"
> 
> The best answer is $*, because you have to use \!*:q to get "$@" behavior
> in csh.  An argument could be made that $==* is even better, but not "$@".

But, to quote Zoltan,

>   It's good habbit to use "$@".  The use of $* is almost always wrong
>   in bourne/korn shell scripts still people use that all the time.

Who cares if it is the behavior that is most equivalent, when the
behavior is not what they want?!?  I remember when I was stuck with
tcsh, back in the days before zsh became useful, I used to *dream* of
having "$@".  When I found out ksh had it, I nearly switched, even
though I couldn't stand the static user interface.  I did switch for all
my shell scripts.

Showing people how to mimic the broken behavior of their old shells is
not necessarily a good way to win converts or friends.  However, I do
think the FAQ should be modified to mention that no, this isn't the the
exact same behavior, this is better.

Btw, can you show even *one* case where a csh user really wants $*
functionality and not "$@"?  And, even if $* by default acted exactly
like "$@", it's a good idea to script so as to be complient with as many
shells as is reasonable.  (That is, going lowest common denominator
bites big-time.  However, when you have two equivalent ways of doing
something, and one is supported in two shells, and one only in zsh, do
the multiple shell one.  When you get a job where you're politically
required to use ksh, you'll be glad you kept up with that practice.
Though, I have this annoying tendancy to start scripts with #!/bin/zsh.
Doesn't work very well...)

Ed the slightly annoyed



Messages sorted by: Reverse Date, Date, Thread, Author