Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] zsh/param/private scoping error
On Wed, Sep 1, 2021 at 4:51 AM Marlon Richert <marlon.richert@xxxxxxxxx> wrote:
>
> % () { private tst; () { tst= } }
> (anon):1: tst: attempt to assign private in nested scope
> %
>
> This is not how one would expect private variables to behave.
But it's how variable scoping behaves in the shell language. If I do
% () { local tst; () { tst=foo } }
Then it is the tst in the surrounding scope that gets altered, not the
global one. If the inner function is INTENDED to create a global, it
should be using "typeset -g" explicitly.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author