-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Reuben Thomas on 4/6/2009 3:57 PM: > The man page says: > > for name [ in word ] ; do list ; done > > which conflicts with the POSIX syntax definition, given in > > http://www.opengroup.org/onlinepubs/000095399/utilities/xcu_chap02.html#tag_02
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. 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 */ Which means the POSIX-mandated syntax should really be represented as: for name [in [word...] ;] do compound-list done I guess we should file a bug report to the Austin group. > > The easiest fix seems to be to put the semicolon above in square > brackets, making it optional, though this risks giving the impression > that the syntax > > for i in foo bar;; do > > would be acceptable, when it's not (even by bash). So, you could give > two explicit definitions: > > for i [;] do list ; done > > and > > for i in word ; do list ; done You missed word... (the ... is important). To keep it on one line, I'd represent the bash syntax as: for name [ in [ name ... ] ; | ; ] do to show that bash supports four varints: 'in ;', 'in name... ;', ';', or blank. - -- 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 iEYEARECAAYFAknclCoACgkQ84KuGfSFAYC+3ACgpuEfKgSslKM2Vnl1sv3i69PW XnMAmQFfqIhjHgwHlB5q7ExsCsR9hXi4 =bD+a -----END PGP SIGNATURE-----