From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4334 invoked by alias); 16 Aug 2012 13:53:43 -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: 30619 Received: (qmail 22647 invoked from network); 16 Aug 2012 13:53:40 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Thu, 16 Aug 2012 13:53:34 +0100 From: Peter Stephenson To: Thomas Moschny , Subject: Re: can't tie already tied scalar Message-ID: <20120816135334.7410b635@pwslap01u.europe.root.pri> In-Reply-To: <20120816120638.7283d27c@andromeda.ipd.uni-karlsruhe.de> References: <20120816120638.7283d27c@andromeda.ipd.uni-karlsruhe.de> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.101.10.18] X-Scanned-By: MailControl 8316.0 (www.mailcontrol.com) on 10.68.1.162 On Thu, 16 Aug 2012 12:06:38 +0200 Thomas Moschny wrote: > With versions after 4.3.11, doing > typeset -Tx FOO foo ; typeset -Tx FOO foo > results in this error: typeset: can't tie already tied scalar: FOO > > This shouldn't fail, as long as as the same scalar is tied to the same > array (with the same separator). There didn't seem any obvious reason why it shouldn't be possible to change the separator by this means. Index: Doc/Zsh/builtins.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v retrieving revision 1.138 diff -p -u -r1.138 builtins.yo --- Doc/Zsh/builtins.yo 7 Mar 2012 06:10:42 -0000 1.138 +++ Doc/Zsh/builtins.yo 16 Aug 2012 12:52:59 -0000 @@ -1552,7 +1552,9 @@ an array to var(SCALAR) is an error, and sets it to be a single-element array. Note that both `tt(typeset -xT ...)' and `tt(export -T ...)' work, but only the scalar will be marked for export. Setting the value using the scalar version causes a split on all -separators (which cannot be quoted). +separators (which cannot be quoted). It is possible to use the +same two tied variables with a different separator character in which +case the variables remain joined as before but the separator is changed. The tt(-g) (global) flag is treated specially: it means that any resulting parameter will not be restricted to local scope. Note that this Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.259 diff -p -u -r1.259 builtin.c --- Src/builtin.c 15 Jul 2012 18:06:41 -0000 1.259 +++ Src/builtin.c 16 Aug 2012 12:52:59 -0000 @@ -2449,7 +2449,20 @@ bin_typeset(char *name, char **argv, Opt && (locallevel == pm->level || !(on & PM_LOCAL))) { if (pm->node.flags & PM_TIED) { unqueue_signals(); - zerrnam(name, "can't tie already tied scalar: %s", asg0.name); + if (!strcmp(asg->name, pm->ename)) { + /* + * Already tied in the fashion requested. + */ + struct tieddata *tdp = (struct tieddata*)pm->u.data; + /* Update join character */ + tdp->joinchar = joinchar; + if (asg0.value) + setsparam(asg0.name, ztrdup(asg0.value)); + return 0; + } else { + zerrnam(name, "can't tie already tied scalar: %s", + asg0.name); + } return 1; } if (!asg0.value && !(PM_TYPE(pm->node.flags) & (PM_ARRAY|PM_HASHED))) Index: Test/B02typeset.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/B02typeset.ztst,v retrieving revision 1.21 diff -p -u -r1.21 B02typeset.ztst --- Test/B02typeset.ztst 5 Nov 2008 13:02:10 -0000 1.21 +++ Test/B02typeset.ztst 16 Aug 2012 12:52:59 -0000 @@ -459,3 +459,12 @@ silent2(){ local silence; silent1; } silent2 0:typeset -g should be silent even without TYPESET_SILENT + + typeset -T TIED_SCALAR tied_array + TIED_SCALAR=foo:bar + print $tied_array + typeset -T TIED_SCALAR=goo:car tied_array + print $tied_array +0:retying arrays to same array works +>foo bar +>goo car -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog