zsh-workers
 help / color / mirror / code / Atom feed
* Lines ending with two backslashes are incorrectly read from history file
@ 2012-04-21 16:39 Hauke Petersen
  2012-04-21 17:43 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Hauke Petersen @ 2012-04-21 16:39 UTC (permalink / raw)
  To: zsh-workers

Hi everyone,

I noticed a problem reading history files that contain lines ending in 
two consecutive backslashes (\\).

     % zsh -f
     % SAVEHIST=10
     % bindkey -p \\
     % fc -W history
     % fc -IR history
     [up-arrow]
     % bindkey -p \
     fc -W history

The backslash preceding the \n seems to be interpreted as line 
continuation here even though it's escaped itself?

     % fc -l
         1  SAVEHIST=10
         2  bindkey -p \\
         3  fc -W history
         4  fc -IR history
         5  bindkey -p \\nfc -W history

I've tested this with: -
4.3.11            on Linux 3.0.0-16-server #29-Ubuntu
4.3.12 and 4.3.17 on CYGWIN_NT-6.1-WOW64 1.7.13(0.260/5/3)
4.3.15            on NetBSD 4.0.1_PATCH

Hope I haven't missed a prior report, I searched the archives but 
haven't found anything about this.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Lines ending with two backslashes are incorrectly read from history file
  2012-04-21 16:39 Lines ending with two backslashes are incorrectly read from history file Hauke Petersen
@ 2012-04-21 17:43 ` Bart Schaefer
  2012-04-21 18:09   ` Hauke Petersen
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2012-04-21 17:43 UTC (permalink / raw)
  To: Hauke Petersen, zsh-workers

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Lines ending with two backslashes are incorrectly read from history file
  2012-04-21 17:43 ` Bart Schaefer
@ 2012-04-21 18:09   ` Hauke Petersen
  0 siblings, 0 replies; 3+ messages in thread
From: Hauke Petersen @ 2012-04-21 18:09 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer (2012-04-21 19:43):
> Does this fix it?

It does. I'll be running the patched version and pipe up if anything 
strange happens.

Thanks!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-04-21 18:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-21 16:39 Lines ending with two backslashes are incorrectly read from history file Hauke Petersen
2012-04-21 17:43 ` Bart Schaefer
2012-04-21 18:09   ` Hauke Petersen

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).