🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Christoph Badura Thu, 21 Jan 1993 16:55
fix for ash's (/bin/sh) for loop parsing (NET2/386BSD)
#398
Author: Christoph Badura
Date: Thu, 21 Jan 1993 16:55
125 lines
3378 bytes
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads