about summary refs log tree commit diff
path: root/Src/subst.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2023-06-06 09:16:46 +0100
committerPeter Stephenson <p.stephenson@samsung.com>2023-06-06 09:16:46 +0100
commit78102120b9c9e7485e7f537864fc2c24fbe0071a (patch)
tree48811d8ad11f2a086e9150d8a7b6f20debb79d90 /Src/subst.c
parent63400fdbc5b8ce639a885629e4b1087b4277691d (diff)
downloadzsh-78102120b9c9e7485e7f537864fc2c24fbe0071a.tar.gz
zsh-78102120b9c9e7485e7f537864fc2c24fbe0071a.tar.xz
zsh-78102120b9c9e7485e7f537864fc2c24fbe0071a.zip
51816: add :S history modifier with pattern match
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 974d6171e..14947ae36 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -4351,6 +4351,8 @@ modify(char **str, char **ptr, int inbrace)
 		break;
 
 	    case 's':
+	    case 'S':
+		hsubpatopt = (**ptr == 'S');
 		c = **ptr;
 		(*ptr)++;
 		ptr1 = *ptr;
@@ -4445,7 +4447,7 @@ modify(char **str, char **ptr, int inbrace)
 		break;
 
 	    case '&':
-		c = 's';
+		c = hsubpatopt ? 'S' : 's';
 		break;
 
 	    case 'g':
@@ -4534,8 +4536,10 @@ modify(char **str, char **ptr, int inbrace)
 			copy = casemodify(tt, CASMOD_UPPER);
 			break;
 		    case 's':
+		    case 'S':
+			hsubpatopt = (c == 'S');
 			if (hsubl && hsubr)
-			    subst(&copy, hsubl, hsubr, gbal);
+			    subst(&copy, hsubl, hsubr, gbal, hsubpatopt);
 			break;
 		    case 'q':
 			copy = quotestring(copy, QT_BACKSLASH_SHOWNULL);
@@ -4620,8 +4624,10 @@ modify(char **str, char **ptr, int inbrace)
 		    *str = casemodify(*str, CASMOD_UPPER);
 		    break;
 		case 's':
+		case 'S':
+		    hsubpatopt = (c == 'S');
 		    if (hsubl && hsubr)
-			subst(str, hsubl, hsubr, gbal);
+			subst(str, hsubl, hsubr, gbal, hsubpatopt);
 		    break;
 		case 'q':
 		    *str = quotestring(*str, QT_BACKSLASH);