From a23d39ce3801c00d686d3ea5c63f0b16545cda30 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Thu, 3 Aug 2000 07:51:53 +0000 Subject: make binding of ^D be used in first column if ignoreeof is set and ^D is bound to a shell function widget (12494) --- ChangeLog | 6 ++++++ Doc/Zsh/options.yo | 5 +++++ Src/Zle/zle_main.c | 52 +++++++++++++++++++++++++++++++--------------------- 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7651f0ca2..611473316 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-08-03 Sven Wischnowsky + + * 12494: Doc/Zsh/options.yo, Src/Zle/zle_main.c: make binding of + ^D be used in first column if ignoreeof is set and ^D is bound to + a shell function widget + 2000-08-02 Peter Stephenson * Andrej: 12487: configure.in, Etc/MACHINES, Src/Makefile.in, diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo index c63982ffe..7e0bba825 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -573,6 +573,11 @@ Do not exit on end-of-file. Require the use of tt(exit) or tt(logout) instead. However, ten consecutive EOFs will cause the shell to exit anyway, to avoid the shell hanging if its tty goes away. + +Also, if this option is set and the Zsh Line Editor is used, widgets +implemented by shell functions can be bound to EOF (normally +Control-D) without printing the normal warning message. This works +only for normal widgets, not for completion widgets. ) pindex(INC_APPEND_HISTORY) cindex(history, incremental appending to a file) diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index e25f11f1e..73c402490 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -76,7 +76,10 @@ mod_export Thingy lbindk, bindk; /**/ int insmode; -static int eofchar, eofsent; +/**/ +mod_export int eofchar; + +static int eofsent; static long keytimeout; #ifdef HAVE_SELECT @@ -556,7 +559,7 @@ zleread(char *lp, char *rp, int flags) reselectkeymap(); selectlocalmap(NULL); bindk = getkeycmd(); - if (!ll && isfirstln && c == eofchar) { + if (!ll && isfirstln && unset(IGNOREEOF) && c == eofchar) { eofsent = 1; break; } @@ -630,26 +633,33 @@ execzlefunc(Thingy func, char **args) } else if((w = func->widget)->flags & (WIDGET_INT|WIDGET_NCOMP)) { int wflags = w->flags; - if(!(wflags & ZLE_KEEPSUFFIX)) - removesuffix(); - if(!(wflags & ZLE_MENUCMP)) { - fixsuffix(); - invalidatelist(); + if (keybuf[0] == eofchar && !keybuf[1] && + !ll && isfirstln && isset(IGNOREEOF)) { + showmsg((!islogin) ? "zsh: use 'exit' to exit." : + "zsh: use 'logout' to logout."); + ret = 1; + } else { + if(!(wflags & ZLE_KEEPSUFFIX)) + removesuffix(); + if(!(wflags & ZLE_MENUCMP)) { + fixsuffix(); + invalidatelist(); + } + if (wflags & ZLE_LINEMOVE) + vilinerange = 1; + if(!(wflags & ZLE_LASTCOL)) + lastcol = -1; + if (wflags & WIDGET_NCOMP) { + int atcurhist = histline == curhist; + compwidget = w; + ret = completecall(args); + if (atcurhist) + histline = curhist; + } else + ret = w->u.fn(args); + if (!(wflags & ZLE_NOTCOMMAND)) + lastcmd = wflags; } - if (wflags & ZLE_LINEMOVE) - vilinerange = 1; - if(!(wflags & ZLE_LASTCOL)) - lastcol = -1; - if (wflags & WIDGET_NCOMP) { - int atcurhist = histline == curhist; - compwidget = w; - ret = completecall(args); - if (atcurhist) - histline = curhist; - } else - ret = w->u.fn(args); - if (!(wflags & ZLE_NOTCOMMAND)) - lastcmd = wflags; r = 1; } else { Eprog prog = getshfunc(w->u.fnnam); -- cgit 1.4.1