about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Src/builtin.c5
-rw-r--r--Src/params.c15
3 files changed, 25 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 2dcf66f34..fbed00bbc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2002-10-10  Oliver Kiddle  <opk@zsh.org>
+
+	* 17794: Src/builtin.c, Src/params.c: fix bugs with tied parameters
+	(prevent tying array elements and find correct parameter under
+	alternate name for unsetting)
+
 2002-10-09  Felix Rosencrantz <f_rosencrantz@yahoo.com>
 
 	* 17793: Completion/Base/Utility/_store_cache: Allow / in cache
diff --git a/Src/builtin.c b/Src/builtin.c
index 95f3b6f57..d36b697bc 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2116,6 +2116,11 @@ bin_typeset(char *name, char **argv, Options ops, int func)
 	    zerrnam(name, "can't tie a variable to itself", NULL, 0);
 	    return 1;
 	}
+	if (strchr(asg0.name, '[') || strchr(asg->name, '[')) {
+	    unqueue_signals();
+	    zerrnam(name, "can't tie array elements", NULL, 0);
+	    return 1;
+	}
 	/*
 	 * Keep the old value of the scalar.  We need to do this
 	 * here as if it is already tied to the same array it
diff --git a/Src/params.c b/Src/params.c
index 72b0f2991..0b3a065ba 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2234,8 +2234,21 @@ unsetparam_pm(Param pm, int altflag, int exp)
     /* remove it under its alternate name if necessary */
     if (pm->ename && !altflag) {
 	altpm = (Param) paramtab->getnode(paramtab, pm->ename);
-	if (altpm)
+	/* tied parameters are at the same local level as each other */
+	oldpm = NULL;
+	while (altpm && altpm->level > pm->level) {
+	    /* param under alternate name hidden by a local */
+	    oldpm = altpm;
+	    altpm = altpm->old;
+	}
+	if (altpm) {
+	    if (oldpm && !altpm->level) {
+		oldpm->old = NULL;
+		/* fudge things so removenode isn't called */
+		altpm->level = 1;
+	    }
 	    unsetparam_pm(altpm, 1, exp);
+	}
     }
 
     /*