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

Re: zsh-workers 43616, typeset doesn't report tied parameters



2018-10-09 10:00:14 +0200, TS:
[...]
> % prv() { print -l "${(t)${(P)1}} ${1}=${(P)1}" ; }
> % IMPORTANTVAR=foo
> % prv IMPORTANTVAR
> scalar IMPORTANTVAR=foo
> % readonly IMPORTANTVAR
[...]
> % importantvar=(buuz)
> % prv IMPORTANTVAR
> scalar-readonly-tag_local IMPORTANTVAR=buuz
> 
> basically currently the readonly flag is bypasable this way for every var
> and therefore mood. Somehow i can't believe this is by design, instead of an
> overlook.
[...]

But no need for that to change the value of a readonly variable.
readonly is not a security feature (except maybe for specials,
but even then that's pointless unless you use the restricted
mode (and even then, I'd argue the shell is not the right place
to restrict the user, it's better to use OS containing
features)).

$ readonly VAR=foo
$ typeset +r VAR
$ VAR=bar
$ echo $VAR
bar

-- 
Stephane



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