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

Re: zsh3.0.0 bug: aliases in if-statement



Peter Stephenson wrote:
> "Bart Schaefer" wrote:
> > IMHO, alias expansion has always happened too soon in zsh, but it greatly
> > complicates matters to go around reshaping syntax trees at execution time.
> 
> Not just too soon, I've often thought, but too much.  I don't like the
> following at all.
> 
> % which ls
> ls: aliased to ls -F
> % foo() { command ls }
> % which foo
> foo () {
>         command ls -F
> }

bash, ksh and pdksh behaves similarily.  Aliases should be thought as
macros which expand during compile time.  That's especially true for global
aliases.  Shell functions can do almost anything that a non-global alias
can.  Adding special checks for aliases in the body of comblex commands
would require reparsing of the body which would make zsh much slower and
the code would become more compicated.  POSIX omitted aliases because shell
functions have much more clear semantics and provide more functionality
than aliases and they are even more portable than aliases.

Zoltan



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