mirror of
https://github.com/zsh-users/zsh
synced 2024-07-21 10:14:19 +00:00
18252: pass ignoreeof as flag to zleread
This commit is contained in:
parent
40c29457f2
commit
4c149a8abc
|
@ -1,5 +1,9 @@
|
||||||
2003-02-17 Peter Stephenson <pws@csr.com>
|
2003-02-17 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* 18252: Src/input.c, Src/loop.c, Src/zsh.h, Src/Zle/zle_main.c:
|
||||||
|
pass ignoreeof settings as flag to zle_main.c, only use option
|
||||||
|
in input.c.
|
||||||
|
|
||||||
* 18251: Src/parse.c, Src/loop.c: 15030 broke `select' a year
|
* 18251: Src/parse.c, Src/loop.c: 15030 broke `select' a year
|
||||||
and a half ago and no-one noticed till now; also make `select'
|
and a half ago and no-one noticed till now; also make `select'
|
||||||
return on an EOF without complaining.
|
return on an EOF without complaining.
|
||||||
|
|
|
@ -616,7 +616,7 @@ getkey(int keytmout)
|
||||||
an infinite loop. The simple way around this was to add
|
an infinite loop. The simple way around this was to add
|
||||||
the counter (icnt) so that this happens 20 times and than
|
the counter (icnt) so that this happens 20 times and than
|
||||||
the shell gives up (yes, this is a bit dirty...). */
|
the shell gives up (yes, this is a bit dirty...). */
|
||||||
if (isset(IGNOREEOF) && icnt++ < 20)
|
if ((zlereadflags & ZLRF_IGNOREEOF) && icnt++ < 20)
|
||||||
continue;
|
continue;
|
||||||
stopmsg = 1;
|
stopmsg = 1;
|
||||||
zexit(1, 0);
|
zexit(1, 0);
|
||||||
|
@ -681,7 +681,8 @@ zlecore(void)
|
||||||
reselectkeymap();
|
reselectkeymap();
|
||||||
selectlocalmap(NULL);
|
selectlocalmap(NULL);
|
||||||
bindk = getkeycmd();
|
bindk = getkeycmd();
|
||||||
if (!ll && isfirstln && unset(IGNOREEOF) && c == eofchar) {
|
if (!ll && isfirstln && !(zlereadflags & ZLRF_IGNOREEOF) &&
|
||||||
|
c == eofchar) {
|
||||||
eofsent = 1;
|
eofsent = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -865,7 +866,7 @@ execzlefunc(Thingy func, char **args)
|
||||||
int wflags = w->flags;
|
int wflags = w->flags;
|
||||||
|
|
||||||
if (keybuf[0] == eofchar && !keybuf[1] &&
|
if (keybuf[0] == eofchar && !keybuf[1] &&
|
||||||
!ll && isfirstln && isset(IGNOREEOF)) {
|
!ll && isfirstln && (zlereadflags & ZLRF_IGNOREEOF)) {
|
||||||
showmsg((!islogin) ? "zsh: use 'exit' to exit." :
|
showmsg((!islogin) ? "zsh: use 'exit' to exit." :
|
||||||
"zsh: use 'logout' to logout.");
|
"zsh: use 'logout' to logout.");
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
@ -986,7 +987,7 @@ bin_vared(char *name, char **args, Options ops, int func)
|
||||||
struct value vbuf;
|
struct value vbuf;
|
||||||
Value v;
|
Value v;
|
||||||
Param pm = 0;
|
Param pm = 0;
|
||||||
int create = 0, ifl, ieof;
|
int create = 0, ifl;
|
||||||
int type = PM_SCALAR, obreaks = breaks, haso = 0;
|
int type = PM_SCALAR, obreaks = breaks, haso = 0;
|
||||||
char *p1 = NULL, *p2 = NULL;
|
char *p1 = NULL, *p2 = NULL;
|
||||||
FILE *oshout = NULL;
|
FILE *oshout = NULL;
|
||||||
|
@ -1145,10 +1146,7 @@ bin_vared(char *name, char **args, Options ops, int func)
|
||||||
if (OPT_ISSET(ops,'h'))
|
if (OPT_ISSET(ops,'h'))
|
||||||
hbegin(2);
|
hbegin(2);
|
||||||
isfirstln = OPT_ISSET(ops,'e');
|
isfirstln = OPT_ISSET(ops,'e');
|
||||||
ieof = opts[IGNOREEOF];
|
|
||||||
opts[IGNOREEOF] = 0;
|
|
||||||
t = (char *) zleread(p1, p2, OPT_ISSET(ops,'h') ? ZLRF_HISTORY : 0);
|
t = (char *) zleread(p1, p2, OPT_ISSET(ops,'h') ? ZLRF_HISTORY : 0);
|
||||||
opts[IGNOREEOF] = ieof;
|
|
||||||
if (OPT_ISSET(ops,'h'))
|
if (OPT_ISSET(ops,'h'))
|
||||||
hend(NULL);
|
hend(NULL);
|
||||||
isfirstln = ifl;
|
isfirstln = ifl;
|
||||||
|
|
|
@ -269,8 +269,10 @@ inputline(void)
|
||||||
* typeahead when the terminal settings are altered.
|
* typeahead when the terminal settings are altered.
|
||||||
* pws 1998/03/12
|
* pws 1998/03/12
|
||||||
*/
|
*/
|
||||||
ingetcline = (char *)zleread(ingetcpmptl, ingetcpmptr,
|
int flags = ZLRF_HISTORY|ZLRF_NOSETTY;
|
||||||
ZLRF_HISTORY|ZLRF_NOSETTY);
|
if (isset(IGNOREEOF))
|
||||||
|
flags |= ZLRF_IGNOREEOF;
|
||||||
|
ingetcline = (char *)zleread(ingetcpmptl, ingetcpmptr, flags);
|
||||||
histdone |= HISTFLAG_SETTY;
|
histdone |= HISTFLAG_SETTY;
|
||||||
}
|
}
|
||||||
if (!ingetcline) {
|
if (!ingetcline) {
|
||||||
|
|
|
@ -202,7 +202,7 @@ execselect(Estate state, int do_exec)
|
||||||
wordcode code = state->pc[-1];
|
wordcode code = state->pc[-1];
|
||||||
char *str, *s, *name;
|
char *str, *s, *name;
|
||||||
LinkNode n;
|
LinkNode n;
|
||||||
int i, usezle, oignoreeof = opts[IGNOREEOF];
|
int i, usezle;
|
||||||
FILE *inp;
|
FILE *inp;
|
||||||
size_t more;
|
size_t more;
|
||||||
LinkList args;
|
LinkList args;
|
||||||
|
@ -238,7 +238,6 @@ execselect(Estate state, int do_exec)
|
||||||
inp = fdopen(dup(usezle ? SHTTY : 0), "r");
|
inp = fdopen(dup(usezle ? SHTTY : 0), "r");
|
||||||
more = selectlist(args, 0);
|
more = selectlist(args, 0);
|
||||||
loop = state->pc;
|
loop = state->pc;
|
||||||
opts[IGNOREEOF] = 0;
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (empty(bufstack)) {
|
if (empty(bufstack)) {
|
||||||
|
@ -302,7 +301,6 @@ execselect(Estate state, int do_exec)
|
||||||
fclose(inp);
|
fclose(inp);
|
||||||
loops--;
|
loops--;
|
||||||
state->pc = end;
|
state->pc = end;
|
||||||
opts[IGNOREEOF] = oignoreeof;
|
|
||||||
return lastval;
|
return lastval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1747,6 +1747,7 @@ struct heap {
|
||||||
|
|
||||||
#define ZLRF_HISTORY 0x01 /* OK to access the history list */
|
#define ZLRF_HISTORY 0x01 /* OK to access the history list */
|
||||||
#define ZLRF_NOSETTY 0x02 /* Don't set tty before return */
|
#define ZLRF_NOSETTY 0x02 /* Don't set tty before return */
|
||||||
|
#define ZLRF_IGNOREEOF 0x04 /* Ignore an EOF from the keyboard */
|
||||||
|
|
||||||
/****************/
|
/****************/
|
||||||
/* Entry points */
|
/* Entry points */
|
||||||
|
|
Loading…
Reference in a new issue