From: Michael Prokop <news@michael-prokop.at>
To: zsh-workers@sunsite.dk
Subject: zsh history gets destroyed when running out of disk space
Date: Mon, 11 Jun 2007 22:22:11 +0200 [thread overview]
Message-ID: <2007-06-11T21-20-52@devnull.michael-prokop.at> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 777 bytes --]
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/
[-- Attachment #1.2: zsh_fix_history_enospc.patch --]
[-- Type: text/x-diff, Size: 864 bytes --]
--- 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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next reply other threads:[~2007-06-11 20:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-11 20:22 Michael Prokop [this message]
2007-06-21 8:04 ` Frank Terbeck
2007-06-22 20:28 ` Peter Stephenson
2007-06-22 22:40 ` Michael Prokop
2007-06-23 18:09 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2007-06-11T21-20-52@devnull.michael-prokop.at \
--to=news@michael-prokop.at \
--cc=zsh-workers@sunsite.dk \
--cc=zsh@michael-prokop.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).