-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Eric Blake on 4/8/2009 6:10 AM: > The corresponding link in POSIX 2008 is: > > http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04 > > although the expository listing in that section is misleading.
I spoke too soon. The online version rendered incorrectly, as: The format for the for loop is as follows: for name [ in [word ... ]]do compound-listdone But the .pdf rendering is correct: The format for the for loop is as follows: for name [ in [word ... ]] do compound-list done Notice that by placing do on a new line, then deferring to the grammar for the cases where newline can be replaced by a semicolon, the printed version has no error after all. > The REAL > POSIX definition is given later in the grammar: > > http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10_02 > > for_clause : For name linebreak do_group > | For name linebreak in sequential_sep do_group > | For name linebreak in wordlist sequential_sep do_group > do_group : Do compound_list Done /* Apply rule 6 */ > linebreak : newline_list > | /* empty */ And one other important production, which shows that semicolon can only appear before 'do' if you also had 'in': sequential_sep : ';' linebreak | newline_list > > > Which means the POSIX-mandated syntax should really be represented as: > > for name [in [word...] ;] do > compound-list > done Hmm. That three-line representation for POSIX still looks valid. But I'm not sure whether I favor the four-line or three-line version. - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAknclysACgkQ84KuGfSFAYBwMgCg0nmatLqwGbo2DyR/ENT29n10 6iAAoLauBFgMA4TeOZ1g60rGpikMMRG/ =TL+1 -----END PGP SIGNATURE-----