Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: 4.3.2/20061219 -> 4.3.2/20070126 very broken



On Sat, 27 Jan 2007 20:15:01 +0300
Alexey Tourbin <at@xxxxxxxxxxx> wrote:
> On Sat, Jan 27, 2007 at 08:07:26PM +0300, Alexey Tourbin wrote:
> > Hello,
> > 4.3.2/20061219 -> 4.3.2/20070126
> > 
> > The prompt cannot be displayed correctly and input is sort of broken
> > (after pressing enter, the command is executed but the prompt is not
> > displayed; pressing enter again gets the prompt back).
> > 
> > git-bisect blames
> > 23097: splitting of $'...' strings in completion
> 
> PS: here is what my prompt is:

Thanks, this combination allowed we to find it quite quickly.  It was a
major oversight in the the change to the way backslashes in $'...' are
handled.  At least, I presume this is the same problem you're
seeing... the results of the bug could be unpredictable.

Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.150
diff -u -r1.150 utils.c
--- Src/utils.c	21 Jan 2007 22:47:41 -0000	1.150
+++ Src/utils.c	27 Jan 2007 18:54:37 -0000
@@ -4914,23 +4914,34 @@
 	} 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;
Index: Test/A03quoting.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A03quoting.ztst,v
retrieving revision 1.1
diff -u -r1.1 A03quoting.ztst
--- Test/A03quoting.ztst	2 Apr 2001 12:30:47 -0000	1.1
+++ Test/A03quoting.ztst	27 Jan 2007 18:54:37 -0000
@@ -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

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author