Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: typeset -T crash



On Wed, 5 Aug 2015 19:59:31 +0200
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> typeset -T i j k; typeset -T j i k

Surely the right fix is something like this?

pws

diff --git a/Src/builtin.c b/Src/builtin.c
index 34bad03..c63be7e 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2674,7 +2674,9 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
 	    && (locallevel == pm->level || !(on & PM_LOCAL))) {
 	    if (pm->node.flags & PM_TIED) {
 		unqueue_signals();
-		if (!strcmp(asg->name, pm->ename)) {
+		if (PM_TYPE(pm->node.flags) != PM_SCALAR) {
+		    zwarnnam(name, "already tied as non-scalar: %s", asg0.name);
+		} else if (!strcmp(asg->name, pm->ename)) {
 		    /*
 		     * Already tied in the fashion requested.
 		     */
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 0a9e253..c7d506a 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1069,6 +1069,11 @@
 >a:b a b
 >x:y:z
 
+  typeset -T tied1 tied2 +
+  typeset -T tied2 tied1 +
+1:Attempts to swap tied variables are safe but futile
+?(eval):typeset:2: already tied as non-scalar: tied2
+
   string='look for a match in here'
   if [[ ${string%%(#b)(match)*} = "look for a " ]]; then
     print $match[1] $mbegin[1] $mend[1] $string[$mbegin[1],$mend[1]]



Messages sorted by: Reverse Date, Date, Thread, Author