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

Re: Lines ending with two backslashes are incorrectly read from history file



On Apr 21,  6:39pm, Hauke Petersen wrote:
}
} I noticed a problem reading history files that contain lines ending in 
} two consecutive backslashes (\\).

Does this fix it?

Index: hist.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/hist.c,v
retrieving revision 1.39
diff -c -r1.39 hist.c
--- hist.c	20 Dec 2011 17:13:38 -0000	1.39
+++ hist.c	21 Apr 2012 17:42:31 -0000
@@ -2220,7 +2225,8 @@
 	}
 	else {
 	    buf[len - 1] = '\0';
-	    if (len > 1 && buf[len - 2] == '\\') {
+	    if (len > 1 && buf[len - 2] == '\\' &&
+		(len < 3 || buf[len - 3] != '\\')) {
 		buf[--len - 1] = '\n';
 		if (!feof(in))
 		    return readhistline(len, bufp, bufsiz, in);



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