1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-03 10:21:46 +02:00

18251: Fix select and make it respect EOF

This commit is contained in:
Peter Stephenson 2003-02-17 11:41:58 +00:00
parent a71bf4a283
commit 40c29457f2
3 changed files with 15 additions and 5 deletions

View file

@ -1,3 +1,9 @@
2003-02-17 Peter Stephenson <pws@csr.com>
* 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'
return on an EOF without complaining.
2003-02-17 Oliver Kiddle <opk@zsh.org> 2003-02-17 Oliver Kiddle <opk@zsh.org>
* 18249: Completion/Linux/Command/_uml: new completion function * 18249: Completion/Linux/Command/_uml: new completion function

View file

@ -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; int i, usezle, oignoreeof = opts[IGNOREEOF];
FILE *inp; FILE *inp;
size_t more; size_t more;
LinkList args; LinkList args;
@ -238,6 +238,7 @@ 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)) {
@ -301,6 +302,7 @@ 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;
} }

View file

@ -923,18 +923,19 @@ par_for(int *complex)
yylex(); yylex();
type = WC_FOR_COND; type = WC_FOR_COND;
} else { } else {
int np, n, posix_in, ona = noaliases, onc = nocorrect; int np = 0, n, posix_in, ona = noaliases, onc = nocorrect;
infor = 0; infor = 0;
if (tok != STRING || !isident(tokstr)) if (tok != STRING || !isident(tokstr))
YYERRORV(oecused); YYERRORV(oecused);
np = ecadd(0); if (!sel)
np = ecadd(0);
n = 0; n = 0;
incmdpos = 1; incmdpos = 1;
noaliases = nocorrect = 1; noaliases = nocorrect = 1;
for (;;) { for (;;) {
n++; n++;
ecstr(tokstr); ecstr(tokstr);
yylex(); yylex();
if (tok != STRING || !strcmp(tokstr, "in") || sel) if (tok != STRING || !strcmp(tokstr, "in") || sel)
break; break;
if (!isident(tokstr) || errflag) if (!isident(tokstr) || errflag)
@ -946,7 +947,8 @@ par_for(int *complex)
} }
noaliases = ona; noaliases = ona;
nocorrect = onc; nocorrect = onc;
ecbuf[np] = n; if (!sel)
ecbuf[np] = n;
posix_in = isnewlin; posix_in = isnewlin;
while (isnewlin) while (isnewlin)
yylex(); yylex();