about summary refs log tree commit diff
path: root/Src/subst.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2015-05-10 19:19:34 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2015-05-10 19:19:34 +0100
commit6269db883ad6989a578bac299deab9c4285bb1df (patch)
tree29639c2221b8b15fc2e9d36ee9f5e03b529dc038 /Src/subst.c
parentbb2362e2c049602b79116aa9570a72dd89711349 (diff)
downloadzsh-6269db883ad6989a578bac299deab9c4285bb1df.tar.gz
zsh-6269db883ad6989a578bac299deab9c4285bb1df.tar.xz
zsh-6269db883ad6989a578bac299deab9c4285bb1df.zip
35067: Add (b) parameter flag for pattern char backslashing.
Doc tweak from Daniel in 35071.

Includes test.
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/Src/subst.c b/Src/subst.c
index f52bcdfc8..bf80495bd 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1592,7 +1592,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
     /* combination of (L), (U) and (C) flags. */
     int casmod = CASMOD_NONE;
     /*
-     * quotemod says we are doing either (q) (positive), (Q) (negative)
+     * quotemod says we are doing either (q/b) (positive), (Q) (negative)
      * or not (0).  quotetype counts the q's for the first case.
      * quoterr is simply (X) but gets passed around a lot because the
      * combination (eX) needs it.
@@ -1861,6 +1861,12 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
 			quotemod++, quotetype++;
 		    }
 		    break;
+		case 'b':
+		    if (quotemod || quotetype != QT_NONE)
+			goto flagerr;
+		    quotemod = 1;
+		    quotetype = QT_BACKSLASH_PATTERN;
+		    break;
 		case 'Q':
 		    quotemod--;
 		    break;
@@ -3460,7 +3466,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
     if (quotemod) {
 	int pre = 0, post = 0;
 
-	if (quotemod > 0 && quotetype > QT_BACKSLASH) {
+	if (quotemod > 0) {
 	    switch (quotetype)
 	    {
 	    case QT_DOLLARS:
@@ -3471,6 +3477,9 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
 
 	    case QT_SINGLE_OPTIONAL:
 		/* quotes will be added for us */
+	    case QT_BACKSLASH:
+	    case QT_BACKSLASH_PATTERN:
+		/* no quotes */
 		break;
 
 	    default: