summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--Src/subst.c17
-rw-r--r--Test/D04parameter.ztst4
3 files changed, 26 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f11641046..98ad613de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-09-12 Peter Stephenson <pws@csr.com>
+
+ * 22689: Src/subst.c, Test/D04parameter.ztst: untokenize
+ strings for substitution in cases like
+ ${${~:-*}//(#m)*/$MATCH=$MATCH}. The pattern code tried
+ to metafy the tokens, which caused chaos.
+
2006-09-11 Peter Stephenson <p.w.stephenson@ntlworld.com>
* unposted: Mikael Magnusson: Doc/Zsh/mod_sched.yo: typos.
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;
}
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 5d48328ed..7c0b28878 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -829,6 +829,10 @@
0:(#m) flag with pure string
>this 4 4 is 7 7 a s 11 11tring
+ print ${${~:-*}//(#m)*/$MATCH=$MATCH}
+0:(#m) flag with tokenized input
+>*=*
+
print -l JAMES${(u)${=:-$(echo yes yes)}}JOYCE
print -l JAMES${(u)${=:-$(echo yes yes she said yes i will yes)}}JOYCE
0:Bug with (u) flag reducing arrays to one element