zsh-workers
 help / color / mirror / code / Atom feed
From: Zoltan Hidvegi  <hzoli@cs.elte.hu>
To: kasahara@csce.kyushu-u.ac.jp (Yoshiaki KASAHARA)
Cc: zsh-workers@math.gatech.edu (zsh-workers)
Subject: Re: history file re-writing in sub-shell
Date: Thu, 7 Sep 1995 22:03:53 +0200 (MET DST)	[thread overview]
Message-ID: <199509072003.WAA01387@bolyai.cs.elte.hu> (raw)
In-Reply-To: <199509071926.EAA15966@biyo.csce.kyushu-u.ac.jp> from "Yoshiaki KASAHARA" at Sep 8, 95 04:26:56 am

> 
> Hello.  I'm not a subscriber of this list, but I found a weirdness
> while using zsh-2.6-beta8 and 10, so I'll report it here.
> 
> After I replaced my zsh from 2.5 to 2.6beta, I found that saved
> history was not read correctly.
> 
> Finally I found that when I use $(non-zsh-builtin-command), the
> content of $HISTFILE is changed (just like when an interactive shell
> exits).  I believe there are something wrong with command
> substitution...  I have never encountered such a problem with zsh 2.5.
> 
> Please send me responses (if any).  Thank you.

I send a `fix' for that in article 337 some time ago, I send it again as noone
responded.  It fixes the problem but is completely disables saving history on
exec since an other bug I'm not going to fix (I have no time and I do not know
exec.c well enough).

Zoltan

>From hzoli Tue Aug 22 16:31:43 1995
Subject: HISTORY saving fixes
To: zsh-workers@math.gatech.edu (zsh-workers)

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

*** 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


  reply	other threads:[~1995-09-07 20:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-09-07 19:26 Yoshiaki KASAHARA
1995-09-07 20:03 ` Zoltan Hidvegi [this message]
1995-09-08 16:29   ` P.Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199509072003.WAA01387@bolyai.cs.elte.hu \
    --to=hzoli@cs.elte.hu \
    --cc=kasahara@csce.kyushu-u.ac.jp \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).