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

[BUG] Trailing backslash in history file confuses entries



Hi,

I noticed this weird behavior:

% zsh --version
zsh 5.8 (x86_64-unknown-linux-gnu)
% zsh -f
rhea% SAVEHIST=9000 HISTSIZE=9000 HISTFILE=/tmp/.zsh_history 
rhea% setopt INC_APPEND_HISTORY EXTENDED_HISTORY
rhea% less foo\<RET><C-c>   # this saves a line with final \ to .zsh_history
rhea% echo bar
bar
rhea% <C-c>
% zsh -f
rhea% SAVEHIST=9000 HISTSIZE=9000 HISTFILE=/tmp/.zsh_history
rhea% fc -R   # load history, same happens without zsh -f by default...
rhea% <UP>
rhea% less foo
: 1636497381:0;echo bar
<C-c>
% tail -n2 /tmp/.zsh_history 
: 1636497373:0;less foo\
: 1636497381:0;echo bar

As you can see, zsh parses the trailing backslash as a line
continuation and assumes the two lines were entered at once
(EXTENDED_HISTORY increases the confusion of the user here).
I assume some kind of escaping has been forgotten in this case.

Thanks,
-- 
Leah Neukirchen  <leah@xxxxxxxx>  https://leahneukirchen.org/




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