zsh-workers
 help / color / mirror / code / Atom feed
* Re: [beta8] history saved on exec doesn't.
@ 1995-05-24 11:17 guthrie
  1995-05-24 13:51 ` P.Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: guthrie @ 1995-05-24 11:17 UTC (permalink / raw)
  To: zsh-list

Mark Borges <mdb@cdc.noaa.gov> wrote:

> >> Mark Borges(mb) wrote on Wed, 17 May 95 09:55:53 MDT:
>
> >> Zoltan Hidvegi(ZH) wrote on Wed, 17 May 1995 12:08:32 +0100 (MET DST):
> ZH> I think that your history is wiped out because setting
> ZH> HISTFILE does not load the history. It's only loaded after
> ZH> the startup scripts. But you exec something from the startup
> ZH> scrips, and since the HISTFILE parameter is already set, zsh
> ZH> saves the (still empty) history. To prevent this either do
> ZH> not set HISTFILE before exec or set the APPEND_HISTORY option
> ZH> (which is useful anyway I think).
>
> mb> I agree, this makes sense. But unfortunately it doesn't
> mb> work. But it probably isn't worth fixing, either.

One other thing that is now borke is if I do any command substitution in
the startup scripts (to set a variable say) after I have set the SAVEHIST
and HISTFILE variables, and I don't have APPEND_HISTORY set, then this wipes
out the history file as well.  (But I guess that this should make sense if
exec is wiping out the history file under these same conditions.)

John Guthrie
guthrie@math.upenn.edu


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [beta8] history saved on exec doesn't.
  1995-05-24 11:17 [beta8] history saved on exec doesn't guthrie
@ 1995-05-24 13:51 ` P.Stephenson
  1995-05-24 15:42   ` Barton E. Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: P.Stephenson @ 1995-05-24 13:51 UTC (permalink / raw)
  To: Zsh hackers list

guthrie@math.upenn.edu wrote:
> Mark Borges <mdb@cdc.noaa.gov> wrote:
> One other thing that is now borke is if I do any command substitution in
> the startup scripts (to set a variable say) after I have set the SAVEHIST
> and HISTFILE variables, and I don't have APPEND_HISTORY set, then this wipes
> out the history file as well.  (But I guess that this should make sense if
> exec is wiping out the history file under these same conditions.)

Actually, this is a good point and I don't think any of the clever
exec stuff should ever be done in a subshell (if forked is set in
execcmd()).  This includes the SHLVL decrement since if you're
exec'ing a command in subshell you should presumably still `see' the
level of the parent shell.  Feel free to find some weird exceptions.

*** Src/exec.c~	Tue May 23 15:36:01 1995
--- Src/exec.c	Wed May 24 14:42:44 1995
***************
*** 1448,1454 ****
  	    }
  
  	} else {
! 	    if (cmd->flags & CFLAG_EXEC) {
  		setiparam("SHLVL", --shlvl);
  		if (unset(NORCS) && interact)
  		    /* save the history file through execs */
--- 1448,1454 ----
  	    }
  
  	} else {
! 	    if ((cmd->flags & CFLAG_EXEC) && !forked) {
  		setiparam("SHLVL", --shlvl);
  		if (unset(NORCS) && interact)
  		    /* save the history file through execs */

-- 
Peter Stephenson <P.Stephenson@swansea.ac.uk>  Tel: +44 1792 205678 extn. 4461
WWW:  http://python.swan.ac.uk/~pypeters/      Fax: +44 1792 295324
Department of Physics, University of Wales, Swansea,
Singleton Park, Swansea, SA2 8PP, U.K.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [beta8] history saved on exec doesn't.
  1995-05-24 13:51 ` P.Stephenson
@ 1995-05-24 15:42   ` Barton E. Schaefer
  1995-05-24 16:55     ` P.Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Barton E. Schaefer @ 1995-05-24 15:42 UTC (permalink / raw)
  To: Zsh hackers list

On May 24,  2:51pm, P.Stephenson@swansea.ac.uk wrote:
} Subject: Re: [beta8] history saved on exec doesn't.
}
} > One other thing that is now broke is if I do any command substitution in
} > the startup scripts (to set a variable say) after I have set the SAVEHIST
} > and HISTFILE variables, and I don't have APPEND_HISTORY set, then this wipes
} > out the history file as well.
}
} Actually, this is a good point and I don't think any of the clever
} exec stuff should ever be done in a subshell (if forked is set in
} execcmd()).  This includes the SHLVL decrement since if you're
} exec'ing a command in subshell you should presumably still `see' the
} level of the parent shell

I confess to have been pretty much ignoring zsh-list at the time this
"clever exec stuff" was being put in, so please pardon any ignorance
in the following questions, but:

I presume "clever exec stuff" really does mean "clever stuff done at
time of an `exec' zsh builtin" and *not* "clever stuff done whenever
any call in the exec(2) family is about to be made".  That is, I can't
believe zsh is now saving history every time any non-builtin command
is run.  Please tell me I'm right.

Then tell me, if I am right, why process substitution would have caused
history to be saved in the first place.  (I completely agree about never
doing anything like this in subshells in general.)

Next, explain "the SHLVL decrement" a bit; I have scripts that depend on
knowing whether they were exec'd from a login shell or from a shell
started via my .xsession, and they presently do it by examining SHLVL.
If SHLVL is suddenly going to start reverting to 1 when a level-2 shell
does an exec, my standard login routine is going to end up in an infinite
loop.  (As you can tell, I haven't installed any of these betas yet.)

Finally, please tell me there's some way to shut off all this stuff and
have an exec just be an exec.  At least some way to shut off saving of
history on exec; I don't know who thinks this is useful, but the last
N things I typically do before any interactive shell would "exec" are
either stuff from my .zlogin or commands I wouldn't want to repeat unless
I were about to do *another* exec, and as such I'd rather the history
were just left alone.  Perhaps one of:

    alias exec='SAVEHIST=0 exec'
    alias exec='HISTFILE=/dev/null exec'

(Or do we still have to use "exec HISTFILE=/dev/null"?)

-- 
Bart Schaefer                     Vice President, Technology, Z-Code Software
schaefer@z-code.com               Division of Network Computing Devices, Inc.
http://www.well.com/www/barts


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [beta8] history saved on exec doesn't.
  1995-05-24 15:42   ` Barton E. Schaefer
@ 1995-05-24 16:55     ` P.Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: P.Stephenson @ 1995-05-24 16:55 UTC (permalink / raw)
  To: schaefer

schaefer@z-code.com wrote:
> I presume "clever exec stuff" really does mean "clever stuff done at
> time of an `exec' zsh builtin" and *not* "clever stuff done whenever
> any call in the exec(2) family is about to be made".  That is, I can't
> believe zsh is now saving history every time any non-builtin command
> is run.  Please tell me I'm right.

yep

> Then tell me, if I am right, why process substitution would have caused
> history to be saved in the first place.  (I completely agree about never
> doing anything like this in subshells in general.)

This is the new code that allows something like $(cmd) to exec the
last command directly from the shell instead of forking as a shortcut.
Certainly nothing funny should have happened here; that was a bug
which the new patch fixes.

> Next, explain "the SHLVL decrement" a bit; I have scripts that depend on
> knowing whether they were exec'd from a login shell or from a shell
> started via my .xsession, and they presently do it by examining SHLVL.
> If SHLVL is suddenly going to start reverting to 1 when a level-2 shell
> does an exec, my standard login routine is going to end up in an infinite
> loop.  (As you can tell, I haven't installed any of these betas yet.)

This was added at popular request to avoid `exec zsh' bumping up
SHLVL, since you can't tell how the new shell started off.  It's still
now `correct' in the sense that it counts how many higher level zsh's
are present (arguably it's more consistent than before when it counted
just the number of zsh's which had ever started up in its past, which
is not something you usually want to know), but that will be off by
one from the previous one, so it looks like you've found another
incompatibility.  In other words, you'd have to check whether SHLVL
was 0 or 1 instead of 1 or 2.  (It does go down to zero like it
should, though; I checked.)

> Finally, please tell me there's some way to shut off all this stuff and
> have an exec just be an exec.  At least some way to shut off saving of
> history on exec; I don't know who thinks this is useful, but the last
> N things I typically do before any interactive shell would "exec" are
> either stuff from my .zlogin or commands I wouldn't want to repeat unless
> I were about to do *another* exec, and as such I'd rather the history
> were just left alone.  Perhaps one of:
> 
>     alias exec='SAVEHIST=0 exec'
>     alias exec='HISTFILE=/dev/null exec'
> 
> (Or do we still have to use "exec HISTFILE=/dev/null"?)

No, this syntax for exec now works (which I didn't realise so I've
only just altered the FAQ), but unfortunately it sets the variable too
late.  Errr... and you can't actually alias exec (somebody else fix
this, I'm tired of endlessly fixing bugs).  The code you need is

      SAVEHIST=0; exec

or perhaps you'd better make that

      ((SHLVL++, SAVEHIST=0)); exec

(In fact, it looks like the main advantage of your upgrading to a more
recent version of zsh would be that you get to complain about the new
features quicker :-/).

-- 
Peter Stephenson <P.Stephenson@swansea.ac.uk>  Tel: +44 1792 205678 extn. 4461
WWW:  http://python.swan.ac.uk/~pypeters/      Fax: +44 1792 295324
Department of Physics, University of Wales, Swansea,
Singleton Park, Swansea, SA2 8PP, U.K.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1995-05-25 15:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-05-24 11:17 [beta8] history saved on exec doesn't guthrie
1995-05-24 13:51 ` P.Stephenson
1995-05-24 15:42   ` Barton E. Schaefer
1995-05-24 16:55     ` P.Stephenson

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).