zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: Re: EOF exiting shell
Date: Tue, 14 Aug 2001 17:04:33 +0100	[thread overview]
Message-ID: <4423.997805073@csr.com> (raw)
In-Reply-To: "Adam Spiers"'s message of "Tue, 14 Aug 2001 16:24:04 BST." <20010814162404.A6900@thelonious.new.ox.ac.uk>

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

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;
     zrefresh();
     while (!done && !errflag) {
+	int maybe_eof;
 
 	statusline = NULL;
 	vilinerange = 0;
 	reselectkeymap();
 	selectlocalmap(NULL);
 	bindk = getkeycmd();
-	if (!ll && isfirstln && unset(IGNOREEOF) && c == eofchar) {
+	maybe_eof = (!ll && isfirstln && c == eofchar);
+	if (maybe_eof && unset(IGNOREEOF)) {
 	    eofsent = 1;
 	    break;
 	}
 	if (bindk) {
 	    if (execzlefunc(bindk, zlenoargs))
+	    {
 		handlefeep(zlenoargs);
+		if (maybe_eof) {
+		    eofsent = 1;
+		    break;
+		}
+	    }
 	    handleprefixes();
 	    /* for vi mode, make sure the cursor isn't somewhere illegal */
 	    if (invicmdmode() && cs > findbol() &&

-- 
Peter Stephenson <pws@csr.com>                  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 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


  reply	other threads:[~2001-08-14 16:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-14 15:24 Adam Spiers
2001-08-14 16:04 ` Peter Stephenson [this message]
2001-08-15 18:49   ` Peter Stephenson
2001-08-16  2:16     ` Bart Schaefer
2001-08-16  9:36       ` Peter Stephenson

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