Subject: Re: "for" behaviour in /bin/sh
To: Simon J. Gerraty <email@example.com>
From: I presume I need no introduction. <firstname.lastname@example.org>
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
* 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.
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.
Humanocentric religions and ways of life have proven to be our undoing.