zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: PATCH: Re: history curiosities
Date: Sun, 18 Jul 1999 16:59:28 +0200	[thread overview]
Message-ID: <9907181459.AA12423@ibmth.df.unipi.it> (raw)
In-Reply-To: "Wayne Davison"'s message of "Sat, 17 Jul 1999 17:03:09 DFT." <Pine.GSO.4.10.9907171537430.29652-100000@house.clari.net>

Wayne Davison wrote:
> On Fri, 16 Jul 1999, Peter Stephenson wrote:
> > I get what I said above; the h is not listed.  Now when I do
> > `history', the `h' is listed but the `history' isn't, i.e. the
> > last two entries shown are `echo three' and `h'.  Now if I do `h'
> > again, the `h' disappears and `history' shows up.
> 
> Yeah, that's all behaving like it should -- history doesn't show
> the command you typed to show the history, and since you have the
> HIST_IGNORE_ALL_DUPS option set, when you re-enter 'h', the older
> 'h' command vanishes.

Hmm, it's strange that aliases are treated as expanded when they don't show
up that way.  I don't particularly like it, but I can live with it.

> > Worse: I now set HISTNOSTORE in addition to the others, type `h',
> > then `!!'.  I get the message `no such event'.
> 
> I am unable to duplicate this using an almost stock 3.1.6-pre-1
> (the only patches I have applied are the ones I'm about to email
> to the list).

The problems show up with a complex precmd() --- in fact, only certain
things in precmd() seem to tickle it.  However, the underlying problems are
easy to see once you find out what's happening.  They both revolve around
remhist(), specifically the code when history is not active.  This does two
things: adds the flag HA_JUNKED to histactive, and frees hist_ring.  Both
cause problems.

The first one is probably not new.  When something gets executed
non-interactively from precmd (or anywhere else, come to that), lexsave()
saves histactive, but doesn't reset it --- so HA_JUNKED is still set, and
curhist gets decreased immediately, then again every time histactive is
restored to its original value by lexrestore().  This can probably be
handled by setting histactive to 0 in lexsave.  This is in the attached
patch --- it seems to fix the problems I was seeing and I can't see how it
can be (very) wrong.

The second is presumably new, and is a bit harder; I only discovered it
because of the first one.  In remhist(), the hist_ring is freed under the
circumstances I'm talking about (a history command with HISTNOSTORE), but
is not set to NULL, so is referred to again with the next hbegin().
Unfortunately, naive fixes --- setting it to NULL, or delaying freeing and
setting it to NULL until the point where HA_JUNKED is handled in hbegin()
--- don't work, because the history number code needs this entry to work
out default history numbers for `history', etc.  It may be easy enough,
just do the the usually stuff for HISTIGNOREDUPS or whatever, only at the
point HA_JUNKED is checked, but I've left this for Wayne to do properly.  I
haven't seen any effects of this bug, but it's clearly not right.

--- Src/lex.c.hist	Sun Jul 18 16:14:32 1999
+++ Src/lex.c	Sun Jul 18 16:44:52 1999
@@ -241,6 +241,7 @@
     cmdsp = 0;
     inredir = 0;
     hdocs = NULL;
+    histactive = 0;
 
     ls->next = lstack;
     lstack = ls;

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


  reply	other threads:[~1999-07-18 15:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-16 13:36 Peter Stephenson
1999-07-17 17:50 ` Bart Schaefer
1999-07-18  0:03 ` Wayne Davison
1999-07-18 14:59   ` Peter Stephenson [this message]
1999-07-19 15:51     ` PATCH: " Peter 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=9907181459.AA12423@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=zsh-workers@sunsite.auc.dk \
    /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).