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

Re: Bug in alias expansion



On Sun, Nov 15, 2015 at 11:48 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Nov 15,  8:03pm, Peter Stephenson wrote:
> }
> } I don't know why this works in other contexts.
>
> Addendum:  To some extent it does not.
>
> torch% alias foo='echo x)$(:'
> torch% print $(foo)
> zsh: command not found: fooecho
>
> This should of course expand to
>
>     print $( echo x)$(: )
>
> which is perfectly valid and definitely should not produce "fooecho",
> so the backtracking is still messed up somewhere and parse_subscript()
> is potentially a red herring.
>
> In older versions of zsh it gagged in a different way:
>
> % alias -g foo='echo x)$(:'
> % print $(foo)
> zsh: parse error near `)'
> zsh: parse error in command substitution

This error is definitely what I would expect from the above command.
It's expanded in the subshell¹, so it shouldn't possibly be able to
affect the syntax of the parent shell.

¹
% alias -g foo=bar
% echo $(foo)
zsh: command not found: bar
% unalias \foo; foo; echo $(foo)
zsh: command not found: bar
zsh: command not found: foo

-- 
Mikael Magnusson



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