about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-12-30 22:35:29 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2017-01-03 14:43:32 -0800
commitd0f7a3b2d6abe48b705dbcde1c601e5224478bee (patch)
tree163dd0de25a8e914b5c0ef7798b407b62e279763
parente90a512aa600580e25617d3a7763c5f0cd5bccd2 (diff)
downloadzsh-d0f7a3b2d6abe48b705dbcde1c601e5224478bee.tar.gz
zsh-d0f7a3b2d6abe48b705dbcde1c601e5224478bee.tar.xz
zsh-d0f7a3b2d6abe48b705dbcde1c601e5224478bee.zip
40248: suppress errors from zshaddhistoryhook
and do not call it if no history entry will be written
-rw-r--r--ChangeLog5
-rw-r--r--Src/hist.c3
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index bec87b8ff..2aafe096f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,11 @@
 	* Paulo Andrade: 40260: Src/prompt.c: Set newly allocated
 	space in prompt buffer to zero as it may be tested.
 
+2016-12-30  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 40248: Src/hist.c: suppress errors from zshaddhistoryhook,
+	and do not call it if no history entry will be written
+
 2016-12-28  Sebastian Gniazdowski  <psprint@fastmail.com>
 
 	* 40231: Src/params.c: Optimise setarrvalue().
diff --git a/Src/hist.c b/Src/hist.c
index 97fd34039..350688d2d 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -1418,7 +1418,7 @@ hend(Eprog prog)
 	DPUTS(hptr < chline, "History end pointer off start of line");
 	*hptr = '\0';
     }
-    {
+    if (*chline) {
 	LinkList hookargs = newlinklist();
 	int save_errflag = errflag;
 	errflag = 0;
@@ -1427,6 +1427,7 @@ hend(Eprog prog)
 	addlinknode(hookargs, chline);
 	callhookfunc("zshaddhistory", hookargs, 1, &hookret);
 
+	errflag &= ~ERRFLAG_ERROR;
 	errflag |= save_errflag;
     }
     /* For history sharing, lock history file once for both read and write */