Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "typeset -p" inconsistency
> On 01/11/2022 05:00 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> % setopt extendedglob
> % typeset -U CDPATH
> % typeset -mp '(#i)cdpath'
> typeset -aT CDPATH cdpath=( )
> typeset -UT CDPATH cdpath=( )
>
> Note the -U attribute is only retained when printing the assignment
> for the scalar ... which is literally correct, since it was only
> asserted for the scalar, but lossy, whereas the array-ness is
> preserved in both cases (as long as typeset remains a reserved word).
That does correctly reflect the behaviour of the -U flag, however.
% typeset -T FOO foo
% foo=(one two three)
% typeset -U foo
% print $foo
one two three
% foo+=(two) # flag applied
% print $foo
one two three
% FOO+=:two # flag not applied
% print $foo
one two three two
Other consequences of this are logical, e.g. "foo=($foo)" does
prune, "typeset -U FOO" works as expected.
The ideal output for typeset -p to reflect how this works might
be to output the typeset -T separately from any indication
of any flags set on one or other of the two interfaces to the
value, i.e. something like what I typed (but with the current
value somewhere).
typeset -T FOO foo=(one two three)
typeset -U foo
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author