about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Src/exec.c2
-rw-r--r--Src/params.c23
-rw-r--r--Src/subst.c2
-rw-r--r--Src/zsh.h1
4 files changed, 11 insertions, 17 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 4ebbf1307..5ee161fff 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -622,7 +622,7 @@ isreallycom(Cmdnam cn)
     else if (!cn->u.name)
 	return 0;
     else {
-	strcpy(fullnam, cn->u.name);
+	strcpy(fullnam, *(cn->u.name));
 	strcat(fullnam, "/");
 	strcat(fullnam, cn->nam);
     }
diff --git a/Src/params.c b/Src/params.c
index 48d6bcf8a..2d04a36b4 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -1217,7 +1217,8 @@ fetchvalue(char **pptr, int bracks, int flags)
 		*pptr = s;
 		return v;
 	    }
-	} else if (v->isarr && iident(*t) && isset(KSHARRAYS))
+	} else if (!(flags & SCANPM_ASSIGNING) && v->isarr &&
+		   iident(*t) && isset(KSHARRAYS))
 	    v->b = 0, v->isarr = 0;
     }
     if (!bracks && *s)
@@ -1649,7 +1650,7 @@ setaparam(char *s, char **val)
 	}
 	v = NULL;
     } else {
-	if (!(v = getvalue(&s, 1)))
+	if (!(v = fetchvalue(&s, 1, SCANPM_ASSIGNING)))
 	    createparam(t, PM_ARRAY);
 	else if (!(PM_TYPE(v->pm->flags) & (PM_ARRAY|PM_HASHED)) &&
 		 !(v->pm->flags & (PM_SPECIAL|PM_TIED))) {
@@ -1660,11 +1661,8 @@ setaparam(char *s, char **val)
 	}
     }
     if (!v)
-	if (!(v = getvalue(&t, 1)))
+	if (!(v = fetchvalue(&t, 1, SCANPM_ASSIGNING)))
 	    return NULL;
-    if (isset(KSHARRAYS) && !ss)
-	/* the whole array should be set instead of only the first element */
-	v->b = -1;
     setarrvalue(v, val);
     return v->pm;
 }
@@ -1688,7 +1686,7 @@ sethparam(char *s, char **val)
 	errflag = 1;
 	return NULL;
     } else {
-	if (!(v = getvalue(&s, 1)))
+	if (!(v = fetchvalue(&s, 1, SCANPM_ASSIGNING)))
 	    createparam(t, PM_HASHED);
 	else if (!(PM_TYPE(v->pm->flags) & PM_HASHED) &&
 		 !(v->pm->flags & PM_SPECIAL)) {
@@ -1697,14 +1695,9 @@ sethparam(char *s, char **val)
 	    v = NULL;
 	}
     }
-    if (!v) {
-	int k = opts[KSHARRAYS];	/* Remember the value of KSHARRAYS */
-	opts[KSHARRAYS] = 0;		/* and clear it to avoid special-  */
-	v = getvalue(&t, 1);		/* case of $array --> ${array[0]}. */
-	opts[KSHARRAYS] = k;		/* OK because we can't assign to a */
-	if (!v)				/* slice of an association anyway, */
-	    return NULL;		/* so ANY subscript will be wrong. */
-    }
+    if (!v)
+	if (!(v = fetchvalue(&t, 1, SCANPM_ASSIGNING)))
+	    return NULL;
     setarrvalue(v, val);
     return v->pm;
 }
diff --git a/Src/subst.c b/Src/subst.c
index 6734218c7..1d739c886 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1028,7 +1028,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 
 	if (!(v = fetchvalue((subexp ? &ov : &s), (wantt ? -1 :
 				  ((unset(KSHARRAYS) || inbrace) ? 1 : -1)),
-			     hkeys|hvals)) ||
+			     hkeys|hvals|(arrasg ? SCANPM_ASSIGNING : 0))) ||
 	    (v->pm && (v->pm->flags & PM_UNSET)))
 	    vunset = 1;
 
diff --git a/Src/zsh.h b/Src/zsh.h
index fe80a17bb..3ba88cd83 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1045,6 +1045,7 @@ struct param {
 #define SCANPM_MATCHKEY   (1<<3)
 #define SCANPM_MATCHVAL   (1<<4)
 #define SCANPM_MATCHMANY  (1<<5)
+#define SCANPM_ASSIGNING  (1<<6)
 #define SCANPM_ISVAR_AT   ((-1)<<15)	/* Only sign bit is significant */
 
 /*