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

Re: path PATH



On Mon, Jan 30, 2023 at 3:41 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
>
> On 2023-01-29 20:41, Bart Schaefer wrote:
> > The explicit purpose of the hideval attribute is to prevent "typeset
> > -p" (and several other things) from displaying/restoring the value.
> >
> Interesting, that's a logical dilemma.  It's like writing into the
> constitution that the constitution cannot be changed.

Are you confusing hideval with readonly? You can change the value of a
hideval parameter like any other.

    % typeset -H foo=bar
    % foo=baz
    % print -r -- $foo
    baz

> 1 /aWorking/Zsh/Source/Wk 0 $ typeset -Hi zzz=123
>
> 1 /aWorking/Zsh/Source/Wk 0 $ typeset -p zzz
> typeset -i zzz
>
> ... that's simply wrong

This output may be confusing to you but it's not wrong. The absence of
"=" in the output means this is a -H parameter.

In one of the previous emails I wrote that you can recreate parameters
in a fresh shell by evaluating the output of `typeset -p` from another
shell. *That* was wrong. The docs don't claim this.

> Hiding the '-H' merely fools you into thinking
> zzz is a plain integer with no value and that's not correct.

This *interpretation* of the output would be incorrect.

> 1 /aWorking/Zsh/Source/Wk 0 $ v zzz
> Iv    zzz = !hidden!
>
> ... so at least you see the attributes correctly

This is a different representation for the same information. You could
argue that this representation is better because it is easier to parse
for a human, or easier to understand correctly, or more difficult to
understand incorrectly. You cannot say that it's more correct though.

>  Is there really no way at all to see the value of a
> hideval?

You can expand a hideval parameter like any other.

    % typeset -H foo=bar
    % print -r -- $foo
    bar

Roman.




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