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

Re: Bugreport zsh 3.1.2: Shell exits prematurely after aborting history-incremental-search-backward



Torsten Hilbrich wrote:
> 
> Sorry, if that bug is already known, but I haven't found any
> mentioning in the BUGS file and the FAQ.

It wasn't known to me.

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

It turns out to be in the input code, which is a part of the shell
last seriously modified by me.  However, there is a flag 'lastc'
containing the last character read which I didn't touch.  For some
reason I haven't quite traced, inputline() fails and sets lastc to
space just in this one case; inerrflush() is called to flush the
input, and since there isn't any this sets lexstop; this is propagated
back to the lexerr when isearch exits, which thinks it marks the end
of input, so the shell exits.

However, its only utility is as a flag that is '\n' after end of line
has been reached; it is never necessary when lexstop is also set,
since that gets checked at the same time, and also the code has no
business setting it to ' ' when inputline() fails since then there's
no line to flush.

So call me adventurous, but I think the code can be simplified so that
lastc is only modified when a real character is returned.  That's what
this does.

*** Src/input.c.inerr	Tue Jun  2 17:16:03 1998
--- Src/input.c	Tue Jun  2 17:27:31 1998
***************
*** 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@xxxxxxxxxxxxxxxxx>       Tel: +39 50 844536
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy



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