* can't tie already tied scalar
@ 2012-08-16 10:06 Thomas Moschny
2012-08-16 12:53 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Moschny @ 2012-08-16 10:06 UTC (permalink / raw)
To: zsh-workers
Hi,
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).
This has been reported earlier, by someone else, see
http://bugs.debian.org/bug=622608 , but seems it didn't get forwarded.
As I'm not subscribed, please CC me.
Regards
Thomas
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: can't tie already tied scalar
2012-08-16 10:06 can't tie already tied scalar Thomas Moschny
@ 2012-08-16 12:53 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2012-08-16 12:53 UTC (permalink / raw)
To: Thomas Moschny, zsh-workers
On Thu, 16 Aug 2012 12:06:38 +0200
Thomas Moschny <thomas.moschny@gmx.de> 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 <pws@csr.com> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-08-16 13:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-16 10:06 can't tie already tied scalar Thomas Moschny
2012-08-16 12:53 ` Peter Stephenson
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).