From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11239 invoked by alias); 28 Feb 2011 06:37:59 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28809 Received: (qmail 4163 invoked from network); 28 Feb 2011 06:37:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110227223740.ZM5361@torch.brasslantern.com> Date: Sun, 27 Feb 2011 22:37:40 -0800 X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Crash bug in typeset -T MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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