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

Re: zsh history gets destroyed when running out of disk space



On Sat, 23 Jun 2007 00:40:09 +0200
Michael Prokop <news@xxxxxxxxxxxxxxxxx> wrote:
> | zsh: failed to write history file /home/grml/.zsh_history.new: unknown error 1182546552
> 
> The error code might be improved though. ;)

Thanks for trying it.

I forgot that %e doesn't use errno directly, it expects an argument
(that's because sometimes we save the number and do something else
before reporting the error).

I've also reset errno to 0 beforehand, on the off chance that one of the
possible failures doesn't set errno.  I don't think that should happen,
but I don't want a stray ENOENT from a previous error confusing the
matter.

Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.67
diff -u -r1.67 hist.c
--- Src/hist.c	22 Jun 2007 20:32:20 -0000	1.67
+++ Src/hist.c	23 Jun 2007 18:05:01 -0000
@@ -2190,6 +2190,7 @@
 	if (isset(SHAREHISTORY))
 	    extended_history = 1;
     }
+    errno = 0;
     if (writeflags & HFILE_APPEND) {
 	tmpfile = NULL;
 	out = fdopen(open(unmeta(fn),
@@ -2302,10 +2303,10 @@
 
     if (ret < 0 && err) {
 	if (tmpfile) {
-	    zerr("failed to write history file %s.new: %e", fn);
+	    zerr("failed to write history file %s.new: %e", fn, errno);
 	    free(tmpfile);
 	} else
-	    zerr("failed to write history file %s: %e", fn);
+	    zerr("failed to write history file %s: %e", fn, errno);
     }
 
     unlockhistfile(fn);

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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