about summary refs log tree commit diff
path: root/Src/lex.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-01-08 22:05:54 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-01-08 22:05:54 +0000
commit94bdf92a06df1aaa1881b14dd7244900222f0551 (patch)
treea3814dabc90b991a5f66c03c6d445e6608aa37d5 /Src/lex.c
parentaab842a0c6c16805120f8390574844478dcb8bbc (diff)
downloadzsh-94bdf92a06df1aaa1881b14dd7244900222f0551.tar.gz
zsh-94bdf92a06df1aaa1881b14dd7244900222f0551.tar.xz
zsh-94bdf92a06df1aaa1881b14dd7244900222f0551.zip
23097: splitting of $'...' strings in completion
Diffstat (limited to 'Src/lex.c')
-rw-r--r--Src/lex.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/Src/lex.c b/Src/lex.c
index a568e25c4..7a0bf2b1c 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -96,18 +96,18 @@ mod_export int addedx;
 mod_export int wb, we;
 
 /* 1 if aliases should not be expanded */
- 
+
 /**/
 mod_export int noaliases;
 
 /* we are parsing a line sent to use by the editor */
- 
+
 /**/
 mod_export int zleparse;
- 
+
 /**/
 mod_export int wordbeg;
- 
+
 /**/
 mod_export int parbegin;
 
@@ -115,7 +115,7 @@ mod_export int parbegin;
 mod_export int parend;
 
 /* don't recognize comments */
- 
+
 /**/
 mod_export int nocomments;
 
@@ -1181,10 +1181,20 @@ gettokstr(int c, int sub)
 		STOPHIST
 		while ((c = hgetc()) != '\'' && !lexstop) {
 		    if (strquote && c == '\\') {
-			add(c);
 			c = hgetc();
 			if (lexstop)
 			    break;
+			/*
+			 * Mostly we don't need to do anything special
+			 * with escape backslashes or closing quotes
+			 * inside $'...'; however in completion we
+			 * need to be able to strip multiple backslashes
+			 * neatly.
+			 */
+			if (c == '\\' || c == '\'')
+			    add(Bnull);
+			else
+			    add('\\');
 		    } else if (!sub && isset(CSHJUNKIEQUOTES) && c == '\n') {
 			if (bptr[-1] == '\\')
 			    bptr--, len--;