zsh-workers
 help / color / mirror / code / Atom feed
* Disabling history saves in init scripts
@ 1995-11-06 23:20 Zoltan Hidvegi
  0 siblings, 0 replies; only message in thread
From: Zoltan Hidvegi @ 1995-11-06 23:20 UTC (permalink / raw)
  To: zsh-workers

Here is a patch which disables history saving from the init scripts.  Explicit
saves with fc are not disabled.

On startup zsh runs all of the init scripts then it examines if the HISTFILE
parameter is set.  If it is set it loads the history from the file it points
to.  This means that we should not save history while executing the init
scripts since we may wipe out the existing history if the HISTFILE parameter
is set.

Cheers,

  Zoltan

*** 1.16	1995/11/05 19:31:55
--- Src/builtin.c	1995/11/06 00:06:18
***************
*** 4464,4470 ****
  	}
      }
      if (unset(NORCS) && interact) {
! 	savehistfile(getsparam("HISTFILE"), 1, isset(APPENDHISTORY) ? 3 : 0);
  	if (islogin && !subsh) {
  	    sourcehome(".zlogout");
  #ifdef GLOBAL_ZLOGOUT
--- 4464,4471 ----
  	}
      }
      if (unset(NORCS) && interact) {
! 	if (!nohistsave)
! 	    savehistfile(getsparam("HISTFILE"), 1, isset(APPENDHISTORY) ? 3 : 0);
  	if (islogin && !subsh) {
  	    sourcehome(".zlogout");
  #ifdef GLOBAL_ZLOGOUT
*** 1.9	1995/11/05 19:41:48
--- Src/exec.c	1995/11/06 00:08:29
***************
*** 1519,1525 ****
  
  	    if (cmd->flags & (CFLAG_EXEC|CFLAG_FAKE_EXEC)) {
  		/* only save the history file on a real exec */
! 		if ((cmd->flags & CFLAG_EXEC) && unset(NORCS) && interact)
  		    savehistfile(getsparam("HISTFILE"), 1, isset(APPENDHISTORY) ? 3 : 0);
  		exit(lastval);
  	    }
--- 1519,1525 ----
  
  	    if (cmd->flags & (CFLAG_EXEC|CFLAG_FAKE_EXEC)) {
  		/* only save the history file on a real exec */
! 		if ((cmd->flags & CFLAG_EXEC) && unset(NORCS) && interact && !nohistsave)
  		    savehistfile(getsparam("HISTFILE"), 1, isset(APPENDHISTORY) ? 3 : 0);
  		exit(lastval);
  	    }
***************
*** 1531,1537 ****
  	    /* only save the history file on a real exec */
  	    if (cmd->flags & CFLAG_EXEC) {
  		setiparam("SHLVL", --shlvl);
! 		if (unset(NORCS) && interact)
  		    /* save the history file through execs */
  		    savehistfile(getsparam("HISTFILE"), 1, isset(APPENDHISTORY) ? 3 : 0);
  	    }
--- 1531,1537 ----
  	    /* only save the history file on a real exec */
  	    if (cmd->flags & CFLAG_EXEC) {
  		setiparam("SHLVL", --shlvl);
! 		if (unset(NORCS) && interact && !nohistsave)
  		    /* save the history file through execs */
  		    savehistfile(getsparam("HISTFILE"), 1, isset(APPENDHISTORY) ? 3 : 0);
  	    }
*** 1.9	1995/11/05 19:59:57
--- Src/globals.h	1995/11/05 19:59:58
***************
*** 98,103 ****
--- 98,107 ----
   * trapping of SIGZERR, SIGEXIT. */
  
  EXTERN int noerrexit;
+ 
+ /* do not save history on exec and exit */
+ 
+ EXTERN int nohistsave;
   
  /* error/break flag */
   
*** 1.9	1995/11/05 20:02:20
--- Src/init.c	1995/11/06 00:05:21
***************
*** 688,693 ****
--- 688,694 ----
      locallevel = sourcelevel = 0;
      trapreturn = 0;
      noerrexit = 0;
+     nohistsave = 1;
      dirstack = newlinklist();
      bufstack = newlinklist();
      hsubl = hsubr = NULL;
***************
*** 796,801 ****
--- 797,803 ----
  	}
      }
      noerrexit = 0;
+     nohistsave = 0;
  }
  
  /* Miscellaneous initializations that happen after init scripts are run */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-11-06 23:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-11-06 23:20 Disabling history saves in init scripts Zoltan Hidvegi

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).