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

Bug: Losing .zsh_history



Due to some hardware problem with the display adapter my box
sometimes fails to show anything on the screen but just emits some
error beeps while it boots.  Since I cannot log in and stop the
machine without the screen, I can only switch off the power.

It has now happened twice that in the wake of the hard switch-off,
~/.zsh_history got completely erased, replaced with all null
characters, but keeping its size (or at least nor being truncated
to zero size).  This is on Linux 4.x (5.x not being compatible
with the very old hardware) using ext 4 without journal, running
Devuan 4.  Losing history is a real big pain because for me
because it's one huge database of past commands and syntax (2
million lines).

(However, I'm not sure why ~/.zsh_history is modified at all
because it should be touched only when logging in?)

I wonder if this situation could be prevented by changing the code
that writes the history file at exit.  Is truncating the file to
zero size part of the procedure?  When I need to write a file in a
safe manner, the procedure normally looks like this:

 * Create file.new
 * Rename file to file.old
 * Rename file.new to file
 (* Possibly sync filesystem)
 * Erase file.old

--

 $ zsh --version
 zsh 5.8 (x86_64-debian-linux-gnu)

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt




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