PATCH: fix :W and :w duplicating input

Mikael Magnusson <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <[email protected]>
Reported in 50991 and introduced in 22525.
---
 Src/subst.c            | 2 +-
 Test/D04parameter.ztst | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Src/subst.c b/Src/subst.c
index f72a6baf27..1776d5e164 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -4737,7 +4737,6 @@ modify(char **str, char **ptr, int inbrace)
 		    *e = '\0';
 		    if (c != 'l' && c != 'u')
 			copy = dupstring(tt);
-		    *e = tc;
 		    switch (c) {
                     case 'a':
 			chabspath(&copy);
@@ -4804,6 +4803,7 @@ modify(char **str, char **ptr, int inbrace)
 			copy = xsymlink(copy, 1);
 			break;
 		    }
+		    *e = tc;
 		    tc = *tt;
 		    *tt = '\0';
 		    nl = al + strlen(t) + strlen(copy);
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 21b1b9dcea..c09821c85e 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1911,6 +1911,14 @@
 >
 >
 
+   wu='aa bb cc'
+   echo $wu:wu
+   W=FOOBAR
+   echo $W:W_B_l
+0:repeated upper/lowercase modifiers
+>AA BB CC
+>fooBar
+
 # This used to cause uncontrolled behaviour, but at best
 # you got the wrong output so the check is worth it.
    args() { print $#; }
-- 
2.38.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.