about summary refs log tree commit diff
path: root/Src/subst.c
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-08-10 18:33:04 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2016-08-10 18:33:04 -0700
commitf7c3aa170b8c36b146ba7644cf3912cb1329a5d2 (patch)
tree1b6c68f5cefa0e01db8b15ee4a2a7cf79e8653db /Src/subst.c
parentcaf48686d0e09691f004a5599a2031edb22cf5c0 (diff)
downloadzsh-f7c3aa170b8c36b146ba7644cf3912cb1329a5d2.tar.gz
zsh-f7c3aa170b8c36b146ba7644cf3912cb1329a5d2.tar.xz
zsh-f7c3aa170b8c36b146ba7644cf3912cb1329a5d2.zip
39019 (cf. PWS 39013): fix SHWORDSPLIT regression introduced by workers/29313
Also add test cases for more join/split combinations
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/Src/subst.c b/Src/subst.c
index e3af15694..ae3e4c40c 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -3454,13 +3454,22 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
      * exception is that ${name:-word} and ${name:+word} will have already
      * done any requested splitting of the word value with quoting preserved.
      */
-    if (ssub || (spbreak && isarr >= 0) || spsep || sep) {
+    if (ssub || spbreak || spsep || sep) {
+	int force_split = !ssub && (spbreak || spsep);
 	if (isarr) {
-	    val = sepjoin(aval, sep, 1);
-	    isarr = 0;
-	    ms_flags = 0;
+	    if (nojoin == 0) {
+		val = sepjoin(aval, sep, 1);
+		isarr = 0;
+		ms_flags = 0;
+	    } else if (force_split && nojoin == 2) {
+		/* Hack to simulate splitting individual elements:
+		 * first join on what we later use to split
+		 */
+		val = sepjoin(aval, spsep, 1);
+		isarr = 0;
+	    }
 	}
-	if (!ssub && (spbreak || spsep)) {
+	if (force_split && !isarr) {
 	    aval = sepsplit(val, spsep, 0, 1);
 	    if (!aval || !aval[0])
 		val = dupstring("");
@@ -3527,7 +3536,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
 	}
 	/*
 	 * TODO:  It would be really quite nice to abstract the
-	 * isarr and !issarr code into a function which gets
+	 * isarr and !isarr code into a function which gets
 	 * passed a pointer to a function with the effect of
 	 * the promptexpand bit.  Then we could use this for
 	 * a lot of stuff and bury val/aval/isarr inside a structure