zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: exit after 10 EOF's
@ 2004-09-13 11:18 Peter Stephenson
  2004-09-13 17:51 ` Bart Schaefer
  2004-09-19  6:50 ` Bart Schaefer
  0 siblings, 2 replies; 22+ messages in thread
From: Peter Stephenson @ 2004-09-13 11:18 UTC (permalink / raw)
  To: Zsh hackers list

The shell is supposed to exit after 10 EOFs if ignore_eof is set.
When zle is in use this appears to have been broken for a long time.
(It's not affected by my recent patch for aborting a list causing the
shell to exit, even though that touched the same code.)

I think the following patch is OK.  It duplicates the usual test from
the top-level loop inside zle, but if we're going to continue with the
feature that the "use 'exit' to exit" message is handled as a zle
message (which doesn't cause a new command line to be output) that seems
to be inevitable.

This ought to be part of the test suite, but with zle it needs zpty and
I don't understand the tests with zpty.

Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.42
diff -u -r1.42 init.c
--- Src/init.c	11 Jul 2004 22:53:03 -0000	1.42
+++ Src/init.c	13 Sep 2004 11:12:47 -0000
@@ -37,7 +37,7 @@
 #include "version.h"
 
 /**/
-int noexitct = 0;
+mod_export 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.50
diff -u -r1.50 zle_main.c
--- Src/Zle/zle_main.c	2 Sep 2004 09:20:39 -0000	1.50
+++ Src/Zle/zle_main.c	13 Sep 2004 11:12:48 -0000
@@ -688,17 +688,27 @@
 	selectlocalmap(NULL);
 	bindk = getkeycmd();
 	if (bindk) {
-	    if (!ll && isfirstln && !(zlereadflags & ZLRF_IGNOREEOF) &&
-		lastchar == eofchar) {
+	    if (!ll && isfirstln && 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.
 		 */
-		eofsent = 1;
-		break;
+		if (!(zlereadflags & ZLRF_IGNOREEOF) ||
+		    ++noexitct >= 10)
+		{
+		    eofsent = 1;
+		    break;
+		}
 	    }
 	    if (execzlefunc(bindk, zlenoargs))
 		handlefeep(zlenoargs);

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


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2004-09-20 14:54 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-13 11:18 PATCH: exit after 10 EOF's 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
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

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