From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Crash bug in typeset -T
Date: Sun, 27 Feb 2011 22:37:40 -0800 [thread overview]
Message-ID: <110227223740.ZM5361@torch.brasslantern.com> (raw)
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
next reply other threads:[~2011-02-28 6:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-28 6:37 Bart Schaefer [this message]
2011-02-28 9:49 ` Peter Stephenson
2011-03-01 4:00 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=110227223740.ZM5361@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).