about summary refs log tree commit diff
path: root/Src/hist.c
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 /Src/hist.c
parent63eaea22384fd2d88ff519ffab8b4378e34d63e9 (diff)
downloadzsh-9534c89981eaa8205c44e6c3b56d6d57bb66f569.tar.gz
zsh-9534c89981eaa8205c44e6c3b56d6d57bb66f569.tar.xz
zsh-9534c89981eaa8205c44e6c3b56d6d57bb66f569.zip
23585: handle errno properly in history save errors
Diffstat (limited to 'Src/hist.c')
-rw-r--r--Src/hist.c5
1 files changed, 3 insertions, 2 deletions
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);