summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2013-10-07 13:01:26 +0100
committerPeter Stephenson <pws@zsh.org>2013-10-07 13:01:26 +0100
commit6f195241f3ee98c11bc93ab089417012767d9cec (patch)
treef70b1059605557945c9e7b6c6c9e649a2bebc5d8
parent9345e57859eda273d2d14346fa48e15b109fbe2d (diff)
downloadzsh-6f195241f3ee98c11bc93ab089417012767d9cec.tar.gz
zsh-6f195241f3ee98c11bc93ab089417012767d9cec.tar.xz
zsh-6f195241f3ee98c11bc93ab089417012767d9cec.zip
31794: further refinement to INCAPPENDHISTORY change.
With SHAREHISTORY we should make sure the code behaves as it always
did, because it takes care about locking a file once for reading
and writing.
-rw-r--r--ChangeLog3
-rw-r--r--Src/hist.c10
2 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index be2f1b1e3..a8dc3b9e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2013-10-07  Peter Stephenson  <p.stephenson@samsung.com>
 
+	* 31794: Src/hist.c: further refinement that SHAREHISTORY should
+	work as it always did because it's careful about file locking.
+
 	* 31793: Src/hist.c (hbegin): Modify 31789 so that the save
 	history here only happens for interactive editing.
 
diff --git a/Src/hist.c b/Src/hist.c
index c58ce8b34..d1af30a29 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -928,7 +928,15 @@ hbegin(int dohist)
 	histactive = HA_ACTIVE | HA_NOINC;
 
     hf = getsparam("HISTFILE");
-    if (isset(INCAPPENDHISTORY) && !(histactive & HA_NOINC) && !strin)
+    /*
+     * For INCAPPENDHISTORY, when interactive, save the history here
+     * as it gives a better estimate of the times of commands.
+     * If SHAREHISTORY is also set continue to do so in the
+     * standard place, because that's safer about reading and
+     * rewriting history atomically.
+     */
+    if (isset(INCAPPENDHISTORY) && !isset(SHAREHISTORY) &&
+	!(histactive & HA_NOINC) && !strin)
 	savehistfile(hf, 0, HFILE_USE_OPTIONS | HFILE_FAST);
 }