* typeset tied array initialization silently dropped for already tied params
@ 2015-08-09 19:47 Mikael Magnusson
2015-08-10 19:19 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Mikael Magnusson @ 2015-08-09 19:47 UTC (permalink / raw)
To: zsh workers
If you already tied SCALAR and array, then doing
typeset -T SCALAR array=(a b c)
silently has no effect, other than changing the separator to : or
whatever you specified there.
typeset -T SCALAR=foo:bar:baz array
does update the value though, and specifying both gives an error as expected.
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: typeset tied array initialization silently dropped for already tied params
2015-08-09 19:47 typeset tied array initialization silently dropped for already tied params Mikael Magnusson
@ 2015-08-10 19:19 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2015-08-10 19:19 UTC (permalink / raw)
To: Mikael Magnusson; +Cc: zsh workers
On Sun, 9 Aug 2015 21:47:17 +0200
Mikael Magnusson <mikachu@gmail.com> wrote:
> If you already tied SCALAR and array, then doing
> typeset -T SCALAR array=(a b c)
> silently has no effect, other than changing the separator to : or
> whatever you specified there.
The answer seems to be not to do that.
diff --git a/Src/builtin.c b/Src/builtin.c
index c63be7e..4a97a31 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2685,6 +2685,8 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
tdp->joinchar = joinchar;
if (asg0.value.scalar)
setsparam(asg0.name, ztrdup(asg0.value.scalar));
+ else if (asg->value.array)
+ setaparam(asg->name, zlinklist2array(asg->value.array));
return 0;
} else {
zwarnnam(name, "can't tie already tied scalar: %s",
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index a059442..2b8e544 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -467,9 +467,12 @@
print $tied_array
typeset -T TIED_SCALAR=goo:car tied_array
print $tied_array
+ typeset -T TIED_SCALAR tied_array=(poo par)
+ print $TIED_SCALAR
0:retying arrays to same array works
>foo bar
>goo car
+>poo:par
(
setopt POSIXBUILTINS
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-10 19:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-09 19:47 typeset tied array initialization silently dropped for already tied params Mikael Magnusson
2015-08-10 19:19 ` 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).