about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/utils.c29
-rw-r--r--Test/A03quoting.ztst4
3 files changed, 29 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index d4def4515..b474eb635 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-27  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 23136: Src/utils.c, Test/A03quoting.ztst: 23097 added Bnulls
+	for backslashes in $'...' strings but then didn't handle them.
+
 2007-01-26  Wayne Davison  <wayned@users.sourceforge.net>
 
 	* unposted: Src/Zle/zle_tricky.c: fixed the error checking of
diff --git a/Src/utils.c b/Src/utils.c
index 4aa5b0799..c0ccc6715 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -4914,23 +4914,34 @@ getkeystring(char *s, int *len, int how, int *misc)
 	} else if (*s == Meta)
 	    *t++ = *++s ^ 32;
 	else {
-	    *t++ = *s;
 	    if (itok(*s)) {
 		if (meta || control) {
 		    /*
 		     * Presumably we should be using meta or control
 		     * on the character representing the token.
 		     */
-		    *s = ztokens[*s - Pound];
+		    *t++ = ztokens[*s - Pound];
 		} else if (how & GETKEY_DOLLAR_QUOTE) {
-		    /*
-		     * We don't want to metafy this, it's a real
-		     * token.
-		     */
-		    *tdest++ = *s;
+		    if (*s == Bnull) {
+			/*
+			 * Bnull is a backslash which quotes a couple
+			 * of special characters that always appear
+			 * literally next.  See strquote handling
+			 * in gettokstr() in lex.c.
+			 */
+			*tdest++ = *++s;
+		    } else {
+			/*
+			 * We don't want to metafy this, it's a real
+			 * token.
+			 */
+			*tdest++ = *s;
+		    }
 		    continue;
-		}
-	    }
+		} else
+		    *t++ = *s;
+	    } else
+		*t++ = *s;
 	}
 	if (meta == 2) {
 	    t[-1] |= 0x80;
diff --git a/Test/A03quoting.ztst b/Test/A03quoting.ztst
index 6cf86e10f..3187382a8 100644
--- a/Test/A03quoting.ztst
+++ b/Test/A03quoting.ztst
@@ -13,6 +13,10 @@
 >'ut queant laxis'
 >"resonare fibris"
 
+  print -r $'\'a \\\' is \'a backslash\' is \'a \\\''
+0:$'-style quotes with backslashed backslashes
+>'a \' is 'a backslash' is 'a \'
+
   print -r ''''
   setopt rcquotes
 # We need to set rcquotes here for the next example since it is