Hi, Problem: Zsh truncates the zsh history file if you are running out of disk space (AKA ENOSPC). If you don't have any space left in your $HOME and exit zsh you'll find an empty $HISTFILE left. Reason: The savehistfile() function in Src/hist.c does not handle write errors very smart. Fix: See attached patch (against version 4.3.4). The fix might need some more work though. For example there should be much more and better error handling; Zsh shouldn't exit with a return value of 0 when such serious errors happen; the user should be informed about the reason why it failed. regards, -mika- -- ,'"`. http://www.michael-prokop.at/ ( grml.org -» Linux Live-CD for texttool-users and sysadmins `._,' http://www.grml.org/
--- Src/hist.c.orig 2007-06-11 21:02:42.000000000 +0200
+++ Src/hist.c 2007-06-11 21:58:37.000000000 +0200
@@ -2158,6 +2158,11 @@
Histent he;
zlong xcurhist = curhist - !!(histactive & HA_ACTIVE);
int extended_history = isset(EXTENDEDHISTORY);
+ int write_file = 1; // by default assume we can write the file
+
+ // make sure we don't write anything in case of an error
+ if (errno == ENOSPC)
+ write_file = 0;
if (!interact || savehistsiz <= 0 || !hist_ring
|| (!fn && !(fn = getsparam("HISTFILE"))))
@@ -2222,7 +2227,7 @@
#endif
}
}
- if (out) {
+ if (out && write_file) {
for (; he && he->histnum <= xcurhist; he = down_histent(he)) {
if ((writeflags & HFILE_SKIPDUPS && he->node.flags & HIST_DUP)
|| (writeflags & HFILE_SKIPFOREIGN && he->node.flags & HIST_FOREIGN)
Attachment:
signature.asc
Description: Digital signature