Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

HISTORY saving fixes



Zsh saves history on each command substitution.  I thought that this bug was
corrected long ago.

The patch below fixes this, and it also saves history when a builtin is
exec'ed.  It also disables history saving on exec in the startup files
(that's what Mark Borges complaind about a lot).  That's because zsh loads
the history file only after processing the startup files so saving it with
append_history unset would wipe out the history.  History saving is also
disabled in zexit for the same reason.

Unfortunately the exec part of this fix does not work as expected.  After
this patch zsh will never save anything on exec.  That is because subsh is
always true since entersubsh is called from exec.c near line 1241 for each
command or builtin executed with exec. This seems illogical for me but I do
not understand these things completely so I'd leave the fix to someone else.

The patch is for vanilla beta10.  For hzoli10.x the first hunk fails but it
can be merged easily by hand, and the really important part is the second
hunk.

Zoltan

PS. I will not read my mails till the end of next week.

*** Src/exec.c.~1~	Mon Aug 21 23:40:20 1995
--- Src/exec.c	Mon Aug 21 23:41:12 1995
***************
*** 1447,1454 ****
  		if (cmd->flags & CFLAG_EXEC) {
  		    if (subsh)
  			_exit(lastval);
! 		    else
! 			exit(lastval);
  		}
  		if (savelist) {
  		    /* Restore variables, freeing the list but not data. */
--- 1447,1456 ----
  		if (cmd->flags & CFLAG_EXEC) {
  		    if (subsh)
  			_exit(lastval);
! 		    if (unset(NORCS) && interact && sourcelevel < 32768)
! 			/* save the history file through execs */
! 			savehistfile(getsparam("HISTFILE"), 1, isset(APPENDHISTORY) ? 3 : 0);
! 		    exit(lastval);
  		}
  		if (savelist) {
  		    /* Restore variables, freeing the list but not data. */
***************
*** 1468,1474 ****
  	} else {
  	    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);
  	    }
--- 1470,1476 ----
  	} else {
  	    if (cmd->flags & CFLAG_EXEC) {
  		setiparam("SHLVL", --shlvl);
! 		if (unset(NORCS) && interact && !subsh && sourcelevel < 32768)
  		    /* save the history file through execs */
  		    savehistfile(getsparam("HISTFILE"), 1, isset(APPENDHISTORY) ? 3 : 0);
  	    }
*** 1.28	1995/08/21 22:02:42
--- Src/builtin.c	1995/08/21 22:04:09
***************
*** 4829,4835 ****
  	    }
  	} else
  	    killrunjobs(); /* send SIGHUP to any jobs left running  */
!     if (unset(NORCS) && interact) {
  	if (isset(APPENDHISTORY))
  	    savehistfile(getsparam("HISTFILE"), 1, 3);
  	else
--- 4829,4835 ----
  	    }
  	} else
  	    killrunjobs(); /* send SIGHUP to any jobs left running  */
!     if (unset(NORCS) && interact && sourcelevel < 32768) {
  	if (isset(APPENDHISTORY))
  	    savehistfile(getsparam("HISTFILE"), 1, 3);
  	else



Messages sorted by: Reverse Date, Date, Thread, Author