about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Src/loop.c4
-rw-r--r--Src/parse.c10
3 files changed, 15 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 666f26473..a105b4806 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
 	* 18249: Completion/Linux/Command/_uml: new completion function
diff --git a/Src/loop.c b/Src/loop.c
index 4da5a50f0..ebb07445b 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -202,7 +202,7 @@ execselect(Estate state, int do_exec)
     wordcode code = state->pc[-1];
     char *str, *s, *name;
     LinkNode n;
-    int i, usezle;
+    int i, usezle, oignoreeof = opts[IGNOREEOF];
     FILE *inp;
     size_t more;
     LinkList args;
@@ -238,6 +238,7 @@ execselect(Estate state, int do_exec)
     inp = fdopen(dup(usezle ? SHTTY : 0), "r");
     more = selectlist(args, 0);
     loop = state->pc;
+    opts[IGNOREEOF] = 0;
     for (;;) {
 	for (;;) {
 	    if (empty(bufstack)) {
@@ -301,6 +302,7 @@ execselect(Estate state, int do_exec)
     fclose(inp);
     loops--;
     state->pc = end;
+    opts[IGNOREEOF] = oignoreeof;
     return lastval;
 }
 
diff --git a/Src/parse.c b/Src/parse.c
index a6c4cd10b..d7aaa9f63 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -923,18 +923,19 @@ par_for(int *complex)
 	yylex();
 	type = WC_FOR_COND;
     } else {
-	int np, n, posix_in, ona = noaliases, onc = nocorrect;
+	int np = 0, n, posix_in, ona = noaliases, onc = nocorrect;
 	infor = 0;
 	if (tok != STRING || !isident(tokstr))
 	    YYERRORV(oecused);
-	np = ecadd(0);
+	if (!sel)
+	    np = ecadd(0);
 	n = 0;
 	incmdpos = 1;
 	noaliases = nocorrect = 1;
 	for (;;) {
 	    n++;
 	    ecstr(tokstr);
-	    yylex();	
+	    yylex();
 	    if (tok != STRING || !strcmp(tokstr, "in") || sel)
 		break;
 	    if (!isident(tokstr) || errflag)
@@ -946,7 +947,8 @@ par_for(int *complex)
 	}
 	noaliases = ona;
 	nocorrect = onc;
-	ecbuf[np] = n;
+	if (!sel)
+	    ecbuf[np] = n;
 	posix_in = isnewlin;
 	while (isnewlin)
 	    yylex();