zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: zsh exits after delete-char-or-list and two ^Cs
Date: Wed, 01 Sep 2004 18:36:15 +0100	[thread overview]
Message-ID: <200409011736.i81HaFv1011455@news01.csr.com> (raw)
In-Reply-To: "Danek Duvall"'s message of "Wed, 25 Aug 2004 10:04:56 PDT." <20040825170456.GA7526@la-z-boy.comfychair.org>

Danek Duvall wrote:
> This happens with 4.0.6, 4.2.0 and 4.2.1, the first two on Linux, the
> latter on Solaris.  If I use delete-char-or-list, then hit control-C twice,
> the first time cancels the command-line where I hit ^D, and the second one
> exits the shell.

Obviously if I tried to look at this today after my holiday it would
just get me all frustrated.  So that would be a bad idea.

Here's a patch.  The problem is that there's a special test to see if
there was an EOF character (which must be ^D for the bug to turn up in
this particular form) at the start of the line.  This test was
erroneously triggered on the second ^C as the input character hadn't
changed from the ^D used to list completion.  The first ^C didn't
trigger it because the line hadn't yet been emptied.  The functions
don't pass back the state properly, so it's difficult to check what
actually happened (i.e. EOF or interrupt); maybe it can be done better
than this.

Note that errflag isn't set at the point of the patch if there was a ^C.
This seems to be deliberate; see the handling of EINTR in getkey().  I
think it's also to do with the lack of distinction between an
interruption and an EOF---in loop(), we exit the command loop, and
hence the shell, if we get an end-of-input token and errflag is *not* set.

I thought about resetting lastchar at the start of each line.  However,
I think there are cases where that doesn't work.

Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.49
diff -u -r1.49 zle_main.c
--- Src/Zle/zle_main.c	13 Jul 2004 09:41:37 -0000	1.49
+++ Src/Zle/zle_main.c	1 Sep 2004 17:15:15 -0000
@@ -687,12 +687,19 @@
 	reselectkeymap();
 	selectlocalmap(NULL);
 	bindk = getkeycmd();
-	if (!ll && isfirstln && !(zlereadflags & ZLRF_IGNOREEOF) &&
-	    lastchar == eofchar) {
-	    eofsent = 1;
-	    break;
-	}
 	if (bindk) {
+	    if (!ll && isfirstln && !(zlereadflags & ZLRF_IGNOREEOF) &&
+		lastchar == eofchar) {
+		/*
+		 * Slight hack: this relies on getkeycmd returning
+		 * a value for the EOF character.  However,
+		 * undefined-key is fine.  That's necessary because
+		 * otherwise we can't distinguish this case from
+		 * a ^C.
+		 */
+		eofsent = 1;
+		break;
+	    }
 	    if (execzlefunc(bindk, zlenoargs))
 		handlefeep(zlenoargs);
 	    handleprefixes();

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


      parent reply	other threads:[~2004-09-01 17:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-25 17:04 Danek Duvall
2004-08-27  0:22 ` Bart Schaefer
2004-09-01 18:10   ` Peter Stephenson
2004-09-01 19:44     ` Bart Schaefer
2004-09-02  9:19       ` Peter Stephenson
2004-09-02 15:15         ` Bart Schaefer
2004-09-03  9:37           ` Peter Stephenson
2004-09-03 18:59             ` Bart Schaefer
2004-09-07 14:08               ` Peter Stephenson
2004-09-08 14:23               ` Peter Stephenson
2004-09-01 17:36 ` Peter Stephenson [this message]

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=200409011736.i81HaFv1011455@news01.csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.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).