bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Misleading syntax in manual


From: Eric Blake
Subject: Re: Misleading syntax in manual
Date: Wed, 08 Apr 2009 06:23:07 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666

-----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             ebb9@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-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]