Return to BSD News archive
Received: by minnie.vk1xwt.ampr.org with NNTP id AA7478 ; Fri, 22 Jan 93 11:45:33 EST Xref: sserve comp.bugs.4bsd:1929 comp.unix.bsd:10279 Newsgroups: comp.bugs.4bsd,comp.unix.bsd Path: sserve!manuel.anu.edu.au!munnari.oz.au!uunet!spool.mu.edu!yale.edu!ira.uka.de!smurf.sub.org!flatlin!bad From: bad@flatlin.ka.sub.org (Christoph Badura) Subject: fix for ash's (/bin/sh) for loop parsing (NET2/386BSD) Organization: Guru Systems/Funware Department Date: Thu, 21 Jan 1993 16:55:14 GMT Message-ID: <C17r03.8up@flatlin.ka.sub.org> Summary: "for variable do" was rejected by parser Lines: 125 Subject: sh(1) bombs on "for var do ..." Index: bin/sh/parser.c, bin/sh/sh.1 Description: When using the for var do ... done variant of the for statement the shell complains about a syntax error. Repeat-By: /bin/sh $ for foo do Syntax error: word unexpected $ ^D Fix: *** parser.c,1 Tue Apr 16 02:23:22 1991 --- parser.c Thu Jan 21 00:47:55 1993 *************** *** 326,331 **** --- 326,333 ---- } *app = NULL; n1->nfor.args = ap; + if (lasttoken != TNL && lasttoken != TSEMI) + synexpect(-1); } else { #ifndef GDB_HACK static const char argvars[5] = {CTLVAR, VSNORMAL|VSQUOTE, *************** *** 337,345 **** n2->narg.backquote = NULL; n2->narg.next = NULL; n1->nfor.args = n2; } - if (lasttoken != TNL && lasttoken != TSEMI) - synexpect(-1); checkkwd = 2; if ((t = readtoken()) == TDO) t = TDONE; --- 339,346 ---- n2->narg.backquote = NULL; n2->narg.next = NULL; n1->nfor.args = n2; + tokpushback++; } checkkwd = 2; if ((t = readtoken()) == TDO) t = TDONE; And this is for the man page. *** sh.1,1 Tue Apr 16 02:23:25 1991 --- sh.1 Thu Jan 21 00:51:54 1993 *************** *** 223,234 **** .I for command looks like .d ! \fBfor\fR variable \fBin\fR word... \fBdo\fR list \fBdone\fR .e The words are expanded, and then the list is executed repeatedly with ! the variable set to each word in turn. .B do and .B done --- 223,236 ---- .I for command looks like .d ! \fBfor\fR variable [\fBin\fR word... ] \fBdo\fR list \fBdone\fR .e The words are expanded, and then the list is executed repeatedly with ! the variable set to each word in turn. If \fBin\fR word ... is omitted ! .B in ! \&"$@" is assumed. .B do and .B done *************** *** 254,260 **** loops. .I Continue continues with the next iteration of the ! .IRnum'th innermost loop. These are implemented as builtin commands. .PP --- 256,262 ---- loops. .I Continue continues with the next iteration of the ! .IR num'th innermost loop. These are implemented as builtin commands. .PP *************** *** 625,631 **** none of them has met with universal approval. The convention used by \fIash\fR and all the programs included in the \fIash\fR distribution is as follows: ! .ta 1i,2i .nf 0 Success. 1 Alternate success. --- 627,633 ---- none of them has met with universal approval. The convention used by \fIash\fR and all the programs included in the \fIash\fR distribution is as follows: ! .ta 1i 2i .nf 0 Success. 1 Alternate success. -- Christoph Badura --- bad@flatlin.ka.sub.org Personally, I don't care whether someone is cool enough to quote Doug Gwyn--I only care whether Doug Gwyn is cool enough to quote. -- Larry Wall