about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2014-06-06 21:56:47 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2014-06-06 21:56:47 +0100
commit7f6dc0fe8e3c9aaec8aa295cc4459eabb8f2ada2 (patch)
tree28093b2432239835d8564e42fb95db47ac84c43b /Src
parent605cc1ba579ad6de619f1dca0f3d2857350a3c07 (diff)
downloadzsh-7f6dc0fe8e3c9aaec8aa295cc4459eabb8f2ada2.tar.gz
zsh-7f6dc0fe8e3c9aaec8aa295cc4459eabb8f2ada2.tar.xz
zsh-7f6dc0fe8e3c9aaec8aa295cc4459eabb8f2ada2.zip
32682 with tweaks: Add INC_APPEND_HISTORY_TIME.
Revert INC_APPEND_HISTORY behaviour.
Diffstat (limited to 'Src')
-rw-r--r--Src/hist.c14
-rw-r--r--Src/options.c1
-rw-r--r--Src/zsh.h1
3 files changed, 11 insertions, 5 deletions
diff --git a/Src/hist.c b/Src/hist.c
index 1182994a2..64f88f559 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -935,9 +935,11 @@ hbegin(int dohist)
 
     hf = getsparam("HISTFILE");
     /*
-     * For INCAPPENDHISTORY, when interactive, save the history here
+     * For INCAPPENDHISTORYTIME, when interactive, save the history here
      * as it gives a better estimate of the times of commands.
      *
+     * If INCAPPENDHISTORY is also set we've already done it.
+     *
      * If SHAREHISTORY is also set continue to do so in the
      * standard place, because that's safer about reading and
      * rewriting history atomically.
@@ -950,7 +952,8 @@ hbegin(int dohist)
      * so that (correctly) nothing happens here.  But it shows
      * I thought about it.
      */
-    if (isset(INCAPPENDHISTORY) && !isset(SHAREHISTORY) &&
+    if (isset(INCAPPENDHISTORYTIME) && !isset(SHAREHISTORY) &&
+	!isset(INCAPPENDHISTORY) &&
 	!(histactive & HA_NOINC) && !strin && histsave_stack_pos == 0)
 	savehistfile(hf, 0, HFILE_USE_OPTIONS | HFILE_FAST);
 }
@@ -1378,7 +1381,8 @@ hend(Eprog prog)
      * For normal INCAPPENDHISTORY case and reasoning, see hbegin().
      */
     if (isset(SHAREHISTORY) ? histfileIsLocked() :
-	(isset(INCAPPENDHISTORY) && histsave_stack_pos != 0))
+	(isset(INCAPPENDHISTORY) || (isset(INCAPPENDHISTORYTIME) &&
+				     histsave_stack_pos != 0)))
 	savehistfile(hf, 0, HFILE_USE_OPTIONS | HFILE_FAST);
     unlockhistfile(hf); /* It's OK to call this even if we aren't locked */
     /*
@@ -2542,7 +2546,7 @@ savehistfile(char *fn, int err, int writeflags)
     }
     if (writeflags & HFILE_USE_OPTIONS) {
 	if (isset(APPENDHISTORY) || isset(INCAPPENDHISTORY)
-	 || isset(SHAREHISTORY))
+	 || isset(INCAPPENDHISTORYTIME) || isset(SHAREHISTORY))
 	    writeflags |= HFILE_APPEND | HFILE_SKIPOLD;
 	else
 	    histfile_linect = 0;
@@ -2578,7 +2582,7 @@ savehistfile(char *fn, int err, int writeflags)
 		tmpfile = NULL;
 		if (err) {
 		    if (isset(APPENDHISTORY) || isset(INCAPPENDHISTORY)
-		     || isset(SHAREHISTORY))
+		     || isset(INCAPPENDHISTORYTIME) || isset(SHAREHISTORY))
 			zerr("rewriting %s would change its ownership -- skipped", fn);
 		    else
 			zerr("rewriting %s would change its ownership -- history not saved", fn);
diff --git a/Src/options.c b/Src/options.c
index e83dc5839..2163bff4d 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -165,6 +165,7 @@ static struct optname optns[] = {
 {{NULL, "ignoreclosebraces",  OPT_EMULATE},		 IGNORECLOSEBRACES},
 {{NULL, "ignoreeof",	      0},			 IGNOREEOF},
 {{NULL, "incappendhistory",   0},			 INCAPPENDHISTORY},
+{{NULL, "incappendhistorytime",   0},			 INCAPPENDHISTORYTIME},
 {{NULL, "interactive",	      OPT_SPECIAL},		 INTERACTIVE},
 {{NULL, "interactivecomments",OPT_BOURNE},		 INTERACTIVECOMMENTS},
 {{NULL, "ksharrays",	      OPT_EMULATE|OPT_BOURNE},	 KSHARRAYS},
diff --git a/Src/zsh.h b/Src/zsh.h
index 620883b81..05d582cda 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2115,6 +2115,7 @@ enum {
     IGNORECLOSEBRACES,
     IGNOREEOF,
     INCAPPENDHISTORY,
+    INCAPPENDHISTORYTIME,
     INTERACTIVE,
     INTERACTIVECOMMENTS,
     KSHARRAYS,