zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@math.gatech.edu
Cc: Torsten Hilbrich <Torsten.Hilbrich@gmx.net>
Subject: Re: Bugreport zsh 3.1.2: Shell exits prematurely after aborting history-incremental-search-backward
Date: Thu, 11 Jun 1998 17:26:04 +0200	[thread overview]
Message-ID: <9806111526.AA19795@ibmth.df.unipi.it> (raw)
In-Reply-To: "Torsten Hilbrich"'s message of "01 Jun 1998 21:57:50 DFT." <877m30ki81.fsf@marvin.bln.de>

Torsten Hilbrich wrote:
> If I startup the zsh I immediatly history-incremental-search-backward
> (^R) in the history.  Instead of executing the found command I simply
> abort using ^C.  Then the next return with or without any command
> given will immediatly exit the shell.  It also happens if there is no
> match found in the backward search.

I had a look at this again, and I believe my previous analysis, that
the lastc variable wasn't getting set properly, was the correct
one.  This time I followed the problem at bit further back.
In my case, /etc/zshenv was being sourced immediately before the
command loop started.  At EOF, inputline() returned false; this caused
ingetc() to set lastc to ' ', the behaviour which I found suspect.
Thus the first time from zleread(), inerrflush() tested lastc, found
it wasn't \n, and assumed, wrongly, there was some junk to flush out.
Knock-on errors from this caused the shell to exit.  Later on, lastc
would be \n because the last input operation was a read from stdin
which didn't return EOF. (You can get the same behaviour at any time
by sourcing a file, followed by the actions Torsten described.)

If there was no /etc/zshenv to source, lastc still wouldn't be \n
because it wasn't initialised, so the same thing happens.

So my patch was correct, with one thing I forgot about:  lastc should
be initialised to \n at startup as a flag that there is no input to
flush.  Here is the complete thing.

*** Src/input.c.inerr	Tue Jun  2 17:16:03 1998
--- Src/input.c	Thu Jun 11 17:01:48 1998
***************
*** 101,107 ****
  static int inbufleft;		/* Characters left in current input
  				   stack element */
  
! static int lastc;		/* used as flag that end of line was reached */
  
  
   /* Input must be stacked since the input queue is used by
--- 101,107 ----
  static int inbufleft;		/* Characters left in current input
  				   stack element */
  
! static int lastc = '\n';	/* used as flag that end of line was reached */
  
  
   /* Input must be stacked since the input queue is used by
***************
*** 179,185 ****
  ingetc(void)
  {
      if (lexstop)
! 	return lastc = ' ';
      for (;;) {
  	if (inbufleft) {
  	    inbufleft--;
--- 179,185 ----
  ingetc(void)
  {
      if (lexstop)
! 	return ' ';
      for (;;) {
  	if (inbufleft) {
  	    inbufleft--;
***************
*** 202,212 ****
  	 */
  	if (strin || errflag) {
  	    lexstop = 1;
! 	    return lastc = ' ';
  	}
  	/* As a last resort, get some more input */
  	if (inputline())
! 	    return lastc = ' ';
      }
  }
  
--- 202,212 ----
  	 */
  	if (strin || errflag) {
  	    lexstop = 1;
! 	    return ' ';
  	}
  	/* As a last resort, get some more input */
  	if (inputline())
! 	    return ' ';
      }
  }
  

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 50 844536
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy


  parent reply	other threads:[~1998-06-11 15:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-01 19:57 Torsten Hilbrich
1998-06-02 15:49 ` Peter Stephenson
1998-06-02 17:41   ` Bart Schaefer
1998-06-03  9:09     ` Peter Stephenson
1998-06-11 15:26 ` Peter Stephenson [this message]
1998-06-12  2:58   ` Bart Schaefer
1998-06-12  9:16     ` Peter Stephenson
1998-06-12 15:38       ` Bart Schaefer
1998-06-12 21:41   ` Torsten Hilbrich

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=9806111526.AA19795@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=Torsten.Hilbrich@gmx.net \
    --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).