From 6371325fdf6ca71e5f9839d65267f1d7c9a8863d Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 12 Sep 2006 09:56:25 +0000 Subject: 22689: untokenize strings used in parameter substitution pattern matching --- ChangeLog | 7 +++++++ Src/subst.c | 17 +++++++++++++++-- Test/D04parameter.ztst | 4 ++++ 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 + + * 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 * 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 -- cgit 1.4.1