Subject: Re: "for" behaviour in /bin/sh
To: Simon J. Gerraty <sjg@quick.com.au>
From: I presume I need no introduction. <greywolf@starwolf.starwolf.com>
List: current-users
Date: 07/13/1998 07:14:13
"Simon J. Gerraty" sez:
/*
 * >But in /bin/sh on SunOS and HP-UX, I get the following error:
 * 
 * >	syntax error: `;' unexpected
 * 
 * >Which is the correct behaviour?
 * 
 * Unless you want to consider /bin/sh frozen at SVr2 (1982?)
 * I'd discount HP-UX as a basis of comparison.  The only shell I've 
 * found on HP-UX that _vaguely_ matches the behaviour of shells on other 
 * systems is ksh - and that's an early one too.

Solaris 2.6's sh does the same thing:

$ for x in ; do echo foo; done
syntax error: `;' unexpected
$ for x in
syntax error: `newline or ;' unexpected
$

 * ... for what its worth NetBSD's manual says:
 * 
 *            for variable in word...
 *            do   list
 *            done
 * 
 * and while "word" can be an empty $*, or $@, that's not the same as leaving
 * out the token altogether.  But again, I'm sure I've seen "word" omitted
 * but like:
 * 
 * 	for i in

Nope.  See above.

 * 	do
 * 		...
 * 	done
 */

I'd say that NetBSD's sh doesn't catch this is a bug, but only by the
"virtue" that no other Bourne Shell that I've seen behaves thusly.



				--*greywolf;
--
Humanocentric religions and ways of life have proven to be our undoing.