Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] Can't mark unset variables as read-only
On Wed, 29 Apr 2015 06:55:56 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Apr 29, 11:36am, Peter Stephenson wrote:
> }
> } +Note that in zsh (unlike other shells) it is still possible
> } +to create a local variable of the same name as this is considered a
> } +different variable (though this variable, too, can be marked readonly).
>
> Hrm, I wonder if that, combined with "typeset" automatically creating
> locals when called in a function context (also a POSIX incompatibility?)
> defeats the whole purpose of an unset readonly?
I don't think so... bash makes these local, too:
$ foo=bar
$ fn() { typeset foo=something_else; echo $foo; }
$ fn
something_else
$ echo $foo
bar
So "foo" in fn is logically something entirely different and I don't
think there's any requirement for it to be treated as readonly;
it's entirely a matter for the definition of "fn".
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author