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

PATCH: splitting of case in history



With HIST_LEX_WORDS, if the history contains

case a in\
(a) foo=4\
;;\
esac

then word splitting gets confused because the newline before the ";;" gets
turned into a ";" that matches the first ";" of the pair.

Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.110
diff -p -u -r1.110 hist.c
--- Src/hist.c	19 May 2011 16:10:48 -0000	1.110
+++ Src/hist.c	27 May 2011 19:50:32 -0000
@@ -2406,6 +2406,13 @@ readhistfile(char *fn, int err, int read
 			    uselex = 0;
 			    break;
 			}
+		    } else if (!strcmp(word, ";") && strpfx(";;", pt)) {
+			/*
+			 * Don't get confused between a semicolon that's
+			 * probably really a newline and a double
+			 * semicolon that's terminating a case.
+			 */
+			continue;
 		    }
 		    words[nwordpos++] = pt - start;
 		    pt += strlen(word);

-- 
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