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

Crash bug in typeset -T



torch% typeset -T FOO foo
torch% typeset -p FOO foo
typeset FOO=''
typeset -a foo
foo=()

So far, so good.  Now:

torch% typeset -T FOO bar
torch% typeset -p FOO foo bar
typeset FOO=''
typeset -a foo
foo=('')
typeset -a bar
bar=()

Curious, look what happened to $foo.  Now:

torch% unset FOO
torch% typeset -p FOO foo bar
typeset: no such variable: FOO
typeset: no such variable: bar
typeset -a foo
foo=()
torch% foo=(x y z)
zsh: segmentation fault (core dumped)  Src/zsh -f

Similar things happen if you unset the array instead of the scalar:

torch% typeset -T FOO foo
torch% typeset -T FOO bar
torch% unset foo
torch% typeset -p FOO foo bar
typeset: no such variable: FOO
typeset: no such variable: foo
typeset -a bar
bar=()
torch% bar=(x y z)
zsh: segmentation fault (core dumped)  Src/zsh -f

This also happens if you unset bar and then assign to foo.  (What I was
looking for when I found this, was a way to untie FOO from foo without
unsetting both of them.)  Related oddness:

torch% typeset -T FOO foo
torch% typeset -T FOO=x:y:z bar
torch% typeset -p FOO foo bar
typeset FOO=x:y:z
typeset -a foo
foo=(x y z)
typeset -a bar
bar=()

Note that foo got the value assigned to FOO, bar did not.  If FOO and foo
were not already tied, bar would have had the value.  Yet:

torch% unset bar
torch% typeset -p FOO foo bar
typeset: no such variable: FOO
typeset: no such variable: bar
typeset -a foo
foo=()

Obviously "typeset -T" needs to check if it's being applied to a parameter
that's already tied ... but what should it do in that case?  Error?  Unset
and then re-tie?  There is precedent for the latter - a change of type of
either variable in the tied pair, unsets the other:

torch% typeset -T FOO=1 foo
torch% typeset -i FOO
torch% typeset -p FOO foo
typeset: no such variable: foo
typeset -i FOO=1

Of course what I was hoping was that "typeset +T" would disentangle the
variables yet leave them independently set, but:

torch% typeset +T FOO
typeset: use unset to remove tied variables



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