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

Re: EOF exiting shell

Adam Spiers wrote:
> Two queries regarding exiting the shell via ^D:
>   - The info pages say that even if IGNOREEOF is set, the shell will
>     exit after ten EOFs, but in zle_main.c it looks like it needs to
>     happen 20 times

That's a slightly different issue --- it tries to read a single character
20 times, and if that fails it assumes the terminal has gone away.  Maybe
that's supposed to take over from the IGNOREEOF test in this case?

> (although for me it never exits with IGNOREEOF set).

Right, I suppose that's a real bug, although I don't know anything about
its history.  It's not documented, anyway, but possibly someone decided the
current way was good enough to avoid shells hanging around too long.  In
which case, the rest of this message is irrelevant, but I'd like to know
for sure, obviously.

It looks like it could be fixed by the following --- if the option isn't
set, handle EOF unconditionally, if it is, handle it only on a feep.
Doesn't seem to conflict with vared's use of ^D's, with or without the -e

If it was intended that IGNOREEOF should display a message but stay on the
same prompt, then this will stomp on that --- for that to work requires a
more complicated patch where the number of EOF's is tested inside zle
and the test in the main code is bypassed.

I'm sure I must be missing something else, though...

Index: Src/Zle/zle_main.c
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.19
diff -u -r1.19 zle_main.c
--- Src/Zle/zle_main.c	2001/07/08 00:32:12	1.19
+++ Src/Zle/zle_main.c	2001/08/14 15:53:03
@@ -560,19 +560,27 @@
     prefixflag = 0;
     while (!done && !errflag) {
+	int maybe_eof;
 	statusline = NULL;
 	vilinerange = 0;
 	bindk = getkeycmd();
-	if (!ll && isfirstln && unset(IGNOREEOF) && c == eofchar) {
+	maybe_eof = (!ll && isfirstln && c == eofchar);
+	if (maybe_eof && unset(IGNOREEOF)) {
 	    eofsent = 1;
 	if (bindk) {
 	    if (execzlefunc(bindk, zlenoargs))
+	    {
+		if (maybe_eof) {
+		    eofsent = 1;
+		    break;
+		}
+	    }
 	    /* for vi mode, make sure the cursor isn't somewhere illegal */
 	    if (invicmdmode() && cs > findbol() &&

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070

The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
If you received this in error, please contact the sender and 
delete the material from any computer.

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