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

Re: Bug report: `setopt noaliases` not respected in `local` statement without assignment.



Aha. So, if I want that aliases don't get expanded in the functions in
https://github.com/junegunn/fzf/blob/master/shell/completion.zsh, then
where should I put the `setopt noaliases` statement? Does it suffice to
just put `emulate -L zsh; setopt localoptions noaliases;` at the top of the
file? I don't want the noaliases option to leak into my own shell
environment.

Or is there a better solution possible here than using noaliases?

On Thu, 26 Mar 2020 at 11:59, Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
wrote:

> On Thu, Mar 26, 2020 at 10:55 AM Marlon Richert
> <marlon.richert@xxxxxxxxx> wrote:
> >
> > Test case:
> >
> > alias -g tail="multitail -Cs --follow-all"
> > f() {
> >   setopt localoptions no_aliases
> >   local tail
> >   tail=1
> >   echo $tail
> > }
>
> Alias expansion happens when functions get parsed. If you don't want
> `tail` to be alias-expanded within function `f`, you need to add
> `setopt no_aliases` before the function of `f`.
>
> > g() {
> >   setopt localoptions no_aliases
> >   local tail=1
> >   echo $tail
> > }
>
> `tail` within `local tail=1` is not subject to global alias expansion.
>
> Roman.
>


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