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

bug: can't write history file



Hello,

After upgrading to 4.3.2, I've found that one of the features I love in zsh is
broken, namely the possibility to use the history file for both root and
non-root sessions.  Now, after I logout from "sudo zsh", I get this:

   zsh: can't write history file /home/dk/.zsh-history

I found that it is savehistfile() to blame, because it apparently is called
with writeflags=0, which bypasses all append/rewrite logic, falling back to
saving the file by renaming it to .zsh-history.new, and (correctly) refusing to
overwrite .zsh-history because the euid is different. If I'm correct in
this, the patch below fixes the problem:

--- hist.c.orig Tue Oct 24 15:45:28 2006
+++ hist.c      Tue Oct 24 15:45:47 2006
@@ -2163,7 +2163,7 @@
            readhistfile(fn, err, 0);
            hist_ignore_all_dups = isset(HISTIGNOREALLDUPS);
            if (histlinect)
-               savehistfile(fn, err, 0);
+               savehistfile(fn, err, writeflags & HFILE_APPEND);
 
            pophiststack();
            histactive = remember_histactive;


-- 
Sincerely,
	Dmitry Karasik




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