Subject: Re: "for" behaviour in /bin/sh
To: Johnny Chi-Lung Lam <jlbg+@andrew.cmu.edu>
From: Simon J. Gerraty <sjg@quick.com.au>
List: current-users
Date: 07/13/1998 23:30:55
>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.

For instance HP's /bin/sh still has the bug where pssing args to
a function resets the shell's command line args - a HP engineer told
me they had no plans to fix it.  HP-UX 10 has the same bug.

As to your question... I have seen that construct used, but can't say
I'd ever do it myself (I've written several 100K lines of portable sh 
scripts over the years :-), 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
	do
		...
	done

--sjg