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

Re: aliases expanding aliases: a bug?

2009/12/1 Jay Berkenbilt <ejb@xxxxxx>:
> I just downloaded zsh 4.3.10, and I am able to reproduce this problem
> with that version.  It appears that if an alias ends with a space,
> arguments that themselves happen to be aliases are expanded, at least in
> some cases.
> I can't imagine that this is desirable or intended behavior.  It's also
> hard for me to see why one would have to have a trailing space in an
> alias that was expected to take arguments, but regardless, it still
> seems like a possible bug.
> Comments?

This is documented behaviour, and very useful in some cases.

       Every token in the shell input is checked to see if there is an
alias defined
       for  it.   If so, it is replaced by the text of the alias if it
is in command
       position (if it could be the first word of a simple command),
or if the alias
       is  global.   If the text ends with a space, the next word in
the shell input
       is treated as though it were in command position for purposes
of alias expan-

consider an alias like
alias foo='xterm -e '
alias bar='ls -l /long\ and\ boring\ path'

which lets you say foo bar

Mikael Magnusson

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