summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-09-12 09:56:25 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-09-12 09:56:25 +0000
commit6371325fdf6ca71e5f9839d65267f1d7c9a8863d (patch)
tree02ecb67fe66dfd1acc3f56939b7b01366d2b9e17 /Src
parent0f4d595902ddf23e89dbe3f5c9373a9a8e26345e (diff)
downloadzsh-6371325fdf6ca71e5f9839d65267f1d7c9a8863d.tar.gz
zsh-6371325fdf6ca71e5f9839d65267f1d7c9a8863d.tar.xz
zsh-6371325fdf6ca71e5f9839d65267f1d7c9a8863d.zip
22689: untokenize strings used in parameter substitution pattern matching
Diffstat (limited to 'Src')
-rw-r--r--Src/subst.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 1e8907d5c..3a2c3e111 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2257,15 +2257,28 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 	    /*
 	     * Either loop over an array doing replacements or
 	     * do the replacment on a string.
+	     *
+	     * We need an untokenized value for matching.
 	     */
 	    if (!vunset && isarr) {
+		char **ap;
+		if (!copied) {
+		    aval = arrdup(aval);
+		    copied = 1;
+		}
+		for (ap = aval; *ap; ap++) {
+		    untokenize(*ap);
+		}
 		getmatcharr(&aval, s, flags, flnum, replstr);
-		copied = 1;
 	    } else {
 		if (vunset)
 		    val = dupstring("");
+		if (!copied) {
+		    val = dupstring(val);
+		    copied = 1;
+		    untokenize(val);
+		}
 		getmatch(&val, s, flags, flnum, replstr);
-		copied = 1;
 	    }
 	    break;
 	}