about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2017-04-02 14:43:27 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2017-04-02 14:43:27 -0700
commit207263a61e54a413d02c52f08d7771dd082d20f1 (patch)
tree30963d2e3cf655a6fe46c4ddecb1e8795de9e811 /Src
parenteaeebeb8bb80cd7e2f5c703c7da31f44a1ab3182 (diff)
downloadzsh-207263a61e54a413d02c52f08d7771dd082d20f1.tar.gz
zsh-207263a61e54a413d02c52f08d7771dd082d20f1.tar.xz
zsh-207263a61e54a413d02c52f08d7771dd082d20f1.zip
40929 (replaces 40598): paramsubst() should always return scalar when PREFORK_SINGLE was passed in from prefork()
Previous commit (74fe4d09) consumed too much of the input linked list,
leading to later expansions being skipped.  This commit converts from
array to string sooner, but may thereby alter rc_expand_param and array
element uniqueness behavior.
Diffstat (limited to 'Src')
-rw-r--r--Src/subst.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/Src/subst.c b/Src/subst.c
index e639c96a8..5b1bf8988 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -446,7 +446,7 @@ singsub(char **s)
  * NULL to use IFS).  The return value is true iff the expansion resulted
  * in an empty list.
  *
- * *ms_flags is set to bits in the enum above as neeed.
+ * *ms_flags is set to bits in the enum above as needed.
  */
 
 /**/
@@ -3779,6 +3779,13 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
      * as a scalar.)
      */
 
+    if (isarr && ssub) {
+	/* prefork() wants a scalar, so join no matter what else */
+	val = sepjoin(aval, NULL, 1);
+	isarr = 0;
+	l->list.flags &= ~LF_ARRAY;
+    }
+
     /*
      * If a multsub result had whitespace at the start and we're
      * splitting and there's a previous string, now's the time to do so.
@@ -4026,18 +4033,6 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
 	    y = dupstring(nulstring);
 	setdata(n, (void *) y);
     }
-    if (isarr && ssub) {
-	/* prefork() wants a scalar, so join no matter what else */
-	LinkNode tn;
-
-	aval = hlinklist2array(l, 0);
-	val = sepjoin(aval, NULL, 1);
-	n = firstnode(l);
-	for (tn = lastnode(l); tn && tn != n; tn = lastnode(l))
-	    uremnode(l, tn);
-	setdata(n, (void *) val);
-	l->list.flags &= ~LF_ARRAY;
-    }
     if (eval)
 	*str = (char *) getdata(n);