zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: PATCH: exit after 10 EOF's
Date: Mon, 20 Sep 2004 14:59:27 +0100	[thread overview]
Message-ID: <200409201359.i8KDxSiC007555@news01.csr.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0409191220000.6971@toltec.zanshin.com>

I've applied these two patches and now I get the message from within zle
(no reprinting of command line) when I have a zle -N widget bound to ^D,
but the shell doesn't exit.  If I use a completion widget I get the
message and the prompt is reprinted from the main shell.

The following is what I have applied.

Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.43
diff -u -r1.43 init.c
--- Src/init.c	13 Sep 2004 13:04:55 -0000	1.43
+++ Src/init.c	20 Sep 2004 13:58:02 -0000
@@ -37,7 +37,7 @@
 #include "version.h"
 
 /**/
-mod_export int noexitct = 0;
+int noexitct = 0;
 
 /* buffer for $_ and its length */
 
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.51
diff -u -r1.51 zle_main.c
--- Src/Zle/zle_main.c	13 Sep 2004 13:04:55 -0000	1.51
+++ Src/Zle/zle_main.c	20 Sep 2004 13:58:07 -0000
@@ -688,30 +688,23 @@
 	selectlocalmap(NULL);
 	bindk = getkeycmd();
 	if (bindk) {
-	    if (!ll && isfirstln && lastchar == eofchar) {
+	    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.
-		 *
-		 * The noxitct test is done in the top-level loop
-		 * if zle is not running.  As we trap EOFs at this
-		 * level inside zle we need to mimic it here.
-		 * If we break, the top-level loop will actually increment
-		 * noexitct an extra time; that doesn't cause any
-		 * problems.
 		 */
-		if (!(zlereadflags & ZLRF_IGNOREEOF) ||
-		    ++noexitct >= 10)
-		{
-		    eofsent = 1;
-		    break;
-		}
+		eofsent = 1;
+		break;
 	    }
-	    if (execzlefunc(bindk, zlenoargs))
+	    if (execzlefunc(bindk, zlenoargs)) {
 		handlefeep(zlenoargs);
+		if (eofsent)
+		    break;
+	    }
 	    handleprefixes();
 	    /* for vi mode, make sure the cursor isn't somewhere illegal */
 	    if (invicmdmode() && cs > findbol() &&
@@ -904,10 +897,17 @@
     } else if((w = func->widget)->flags & (WIDGET_INT|WIDGET_NCOMP)) {
 	int wflags = w->flags;
 
-	if (keybuf[0] == eofchar && !keybuf[1] &&
+	/*
+	 * The rule is that "zle -N" widgets suppress EOF warnings.  When
+	 * a "zle -N" widget invokes "zle another-widget" we pass through
+	 * this code again, but with actual arguments rather than with the
+	 * zlenoargs placeholder.
+	 */
+	if (keybuf[0] == eofchar && !keybuf[1] && args == zlenoargs &&
 	    !ll && isfirstln && (zlereadflags & ZLRF_IGNOREEOF)) {
 	    showmsg((!islogin) ? "zsh: use 'exit' to exit." :
 		    "zsh: use 'logout' to logout.");
+	    eofsent = 1;
 	    ret = 1;
 	} else {
 	    if(!(wflags & ZLE_KEEPSUFFIX))

-- 
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-20 14:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-13 11:18 Peter Stephenson
2004-09-13 17:51 ` Bart Schaefer
2004-09-15  9:46   ` Peter Stephenson
2004-09-15 15:43     ` Bart Schaefer
2004-09-15 16:02       ` Bart Schaefer
2004-09-15 16:14         ` Peter Stephenson
2004-09-16 14:57           ` Peter Stephenson
2004-09-16 16:12             ` Bart Schaefer
2004-09-16 16:28               ` Peter Stephenson
2004-09-19  6:50 ` Bart Schaefer
2004-09-19  7:45   ` Duncan Sinclair
2004-09-19 16:41     ` Bart Schaefer
2004-09-19 17:52       ` Peter Stephenson
2004-09-19 18:26         ` Bart Schaefer
2004-09-19 19:25           ` Bart Schaefer
2004-09-20 10:15             ` Peter Stephenson
2004-09-20 13:59             ` Peter Stephenson [this message]
2004-09-20 14:43               ` Bart Schaefer
2004-09-20 14:53                 ` Peter Stephenson
2004-09-19 19:11         ` Bart Schaefer
2004-09-19 11:53   ` Peter Stephenson
2004-09-19 17:00     ` Bart Schaefer

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=200409201359.i8KDxSiC007555@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).