about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-06-23 18:15:14 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-06-23 18:15:14 +0000
commit9534c89981eaa8205c44e6c3b56d6d57bb66f569 (patch)
tree6dd2dbd69a83b6dc6abe83e262de86aa45a95fcd
parent63eaea22384fd2d88ff519ffab8b4378e34d63e9 (diff)
downloadzsh-9534c89981eaa8205c44e6c3b56d6d57bb66f569.tar.gz
zsh-9534c89981eaa8205c44e6c3b56d6d57bb66f569.tar.xz
zsh-9534c89981eaa8205c44e6c3b56d6d57bb66f569.zip
23585: handle errno properly in history save errors
-rw-r--r--ChangeLog4
-rw-r--r--Src/hist.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index b2d222614..75bed5567 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-06-23  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 23585: Src/hist.c: handle errno when handling errors.
+
 2007-06-22  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* 23581: Src/hist.c: handle errors in writing history file
diff --git a/Src/hist.c b/Src/hist.c
index a02163ff7..6ddfaf506 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2190,6 +2190,7 @@ savehistfile(char *fn, int err, int writeflags)
 	if (isset(SHAREHISTORY))
 	    extended_history = 1;
     }
+    errno = 0;
     if (writeflags & HFILE_APPEND) {
 	tmpfile = NULL;
 	out = fdopen(open(unmeta(fn),
@@ -2302,10 +2303,10 @@ savehistfile(char *fn, int err, int writeflags)
 
     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);