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

Re: How should empty aliases work?



On Fri, Dec 29, 2017 at 12:30 AM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> % alias empty=''
> % alias output='empty echo'
> % alias echo='print -r bar'
> % output foo
>
> What actually happens is that "echo" expands and "print -r bar foo" is
> executed.  If that's correct, can someone explain why?

I think the answer is that being a word in command position has
precedence over being a word preceded by an alias replacement.  Words
in command position are always alias-replaceable; words not in command
position are alias-replaceable if preceded by an alias replacement
that ended with a space.

So when "empty" disappears, it leaves "echo" in command position and
the first clause applies even though the second clause does not.



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