summary refs log tree commit diff
diff options
context:
space:
mode:
-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);