From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29337 invoked from network); 20 Sep 2004 14:44:57 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 20 Sep 2004 14:44:57 -0000 Received: (qmail 40931 invoked from network); 20 Sep 2004 14:44:50 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 20 Sep 2004 14:44:50 -0000 Received: (qmail 8516 invoked by alias); 20 Sep 2004 14:44:37 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20395 Received: (qmail 8502 invoked from network); 20 Sep 2004 14:44:37 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 20 Sep 2004 14:44:37 -0000 Received: (qmail 40251 invoked from network); 20 Sep 2004 14:43:39 -0000 Received: from moonbase.zanshin.com (64.84.47.139) by a.mx.sunsite.dk with SMTP; 20 Sep 2004 14:43:37 -0000 Received: from toltec.zanshin.com (toltec.zanshin.com [64.84.47.166]) by moonbase.zanshin.com (8.13.1/8.13.1) with ESMTP id i8KEhUCn005233; Mon, 20 Sep 2004 07:43:30 -0700 Date: Mon, 20 Sep 2004 07:43:30 -0700 (PDT) From: Bart Schaefer Reply-To: zsh-workers@sunsite.dk To: Peter Stephenson cc: zsh-workers@sunsite.dk Subject: Re: PATCH: exit after 10 EOF's In-Reply-To: <200409201359.i8KDxSiC007555@news01.csr.com> Message-ID: References: <200409131118.i8DBIM5B005245@news01.csr.com> <20040919175211.3557D863A@pwstephenson.fsnet.co.uk> <200409201359.i8KDxSiC007555@news01.csr.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.0 required=6.0 tests=BAYES_44 autolearn=no version=2.63 X-Spam-Hits: -0.0 On Mon, 20 Sep 2004, Peter Stephenson wrote: > 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, I can't reproduce this. I tried: zagzig% widget() { : } zagzig% zle -N widget zagzig% bindkey \^D widget zagzig% setopt ignoreeof zagzig% (typing ctrl-D several times does nothing). I then did: zagzig% widget() { LBUFFER+=$KEYS } zagzig% ^D^D^D^D^D^D^D I next did: zagzig% widget() { zle self-insert } zagzig% ^D^D^D^D^D^D^D Can you give me the exact command sequence you used? > but the shell doesn't exit. That part I can reproduce, but then, it's not supposed to exit. > If I use a completion widget I get the message and the prompt is > reprinted from the main shell. Hmm, yes, I hadn't noticed that difference. There's no other way to keep the noexitct increment limited to the top-level loop, though. Is this really a problem? For reference, what I have is: Index: Src/init.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/init.c,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- Src/init.c 13 Sep 2004 13:04:55 -0000 1.43 +++ Src/init.c 20 Sep 2004 13:37:41 -0000 1.44 @@ -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 retrieving revision 1.53 diff -u -r1.51 -r1.53 --- Src/Zle/zle_main.c 13 Sep 2004 13:04:55 -0000 1.51 +++ Src/Zle/zle_main.c 20 Sep 2004 14:04:03 -0000 1.53 @@ -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))