Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: exit after 10 EOF's
- X-seq: zsh-workers 20387
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: PATCH: exit after 10 EOF's
- Date: Sun, 19 Sep 2004 11:26:28 -0700 (PDT)
- In-reply-to: <20040919175211.3557D863A@xxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <200409131118.i8DBIM5B005245@xxxxxxxxxxxxxx> <Pine.LNX.4.61.0409181943300.6971@xxxxxxxxxxxxxxxxxx> <D8064C1C-0A0F-11D9-A0DD-0003931123E4@xxxxxxxxxxxxxxxx> <Pine.LNX.4.61.0409190935150.6971@xxxxxxxxxxxxxxxxxx> <20040919175211.3557D863A@xxxxxxxxxxxxxxxxxxxxxxxx>
- Reply-to: zsh-workers@xxxxxxxxxx
On Sun, 19 Sep 2004, Peter Stephenson wrote:
> Bart Schaefer wrote:
> >
> > You may have hit on the solution. Rather than counting the number of EOF
> > key presses, count the number of warnings printed.
>
> Yes, that sounds OK. If we could somehow make it (without too much
> tortuous code) that any zle -N widget, no matter what it contains,
> suppresses the warning and the EOF behaviour, I would be fairly happy.
I haven't gotten to the latter part yet, but here's a patch that (a) backs
out 20363 and (b) causes the count to apply to printing of the warning.
The actual implementation is that, with ignoreeof set, ZLE pretends it
received an EOF only when it also prints a warning about it. The counter
in the toplevel loop then suffices and we don't have to count warnings.
> My main remaining unhappiness is with the structure of the code, which
> is why the message and the exiting are separate as patched; the same
> test occurs in two places (not counting the main loop in the main
> shell). However, maybe that can be fixed, too.
Well, sort of. See what you think.
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 19 Sep 2004 18:24:52 -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 19 Sep 2004 18:24:52 -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() &&
@@ -908,6 +901,7 @@
!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))
Messages sorted by:
Reverse Date,
Date,
Thread,
Author