zsh-workers
 help / color / mirror / code / Atom feed
* zsh: corrupt history file
@ 2020-07-29 14:32 Perette Barella
  2020-07-29 14:39 ` Roman Perepelitsa
  0 siblings, 1 reply; 7+ messages in thread
From: Perette Barella @ 2020-07-29 14:32 UTC (permalink / raw)
  To: zsh-workers

Research on Google suggests the 'corrupt history file' problem is rare. 
In my experience, it is not; I get these _all_ _the_ _time_.

I've identified one source of corruption: $HISTFILE.  Korn shell *uses* 
but does not *require* this variable be set.  If unset, it uses 
~/.sh_history as a default.  `zsh` *requires* this variable be set, or 
there is no persistent history feature.  However, once set, if the user 
enters `ksh` (shelling out from an editor, for instance; or starting 
another shell to run a few experiments to compare behavior and increase 
understanding, or try commands to ensure a solution is portable for a 
script), then Korn shell does what it's told and appends its commands to 
the .zsh_history file.  And a `corrupt history file` ensues.

This does not happen with bash; although bash uses $HISTFILE it seems to 
use a similar history format to zsh.  ksh does some unusual encoding.

A solution to this is to add to .kshrc a `HISTFILE=$HOME/.sh_history` 
and to .zshrc a `HISTFILE=$HOME/.zsh_history`, so that if invoking 
different shells they do not corrupt each other's history files.

This issue should be noted in the man page, either with $HISTFILE's 
explanation, or in the BUGS section.


When corruption *does* occur, it is compounded by zsh's behavior: all 
sessions sitting at prompts, will ignore their next command and display 
the corruption error message.  Then they starts working normally again, 
history and all.  It sucks that I lost the past, but having every window 
drop one command gets super frustrating; essentially, this error isn't 
just effecting the history, it's effecting the future.

Even if the past has to be lost, it would be much less frustrating to 
have zsh *execute the inputted command*, then display the error before 
prompting for the next command.  For me, this is the real irritation, 
usually more than losing any history.

Perette Barella


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

end of thread, other threads:[~2020-07-30  4:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29 14:32 zsh: corrupt history file Perette Barella
2020-07-29 14:39 ` Roman Perepelitsa
2020-07-29 15:15   ` Perette Barella
2020-07-29 15:21     ` Eric Cook
2020-07-29 23:07       ` Daniel Shahaf
2020-07-30  3:56         ` Eric Cook
2020-07-30  4:30           ` Daniel Shahaf

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