Clint Adams wrote:
> On Sat, Nov 13, 2010 at 10:31:12PM -0600, Jonathan Nieder wrote:

>> No, only the former.
>
> And what is the syntactic significance of the distinction there?

Sorry, that was cryptic of me.

The grammar of shell command language is defined in [1].  It says:

 for_clause       : For name linebreak                            do_group
                  | For name linebreak in          sequential_sep do_group
                  | For name linebreak in wordlist sequential_sep do_group
                  ;

 linebreak        : newline_list
                  | /* empty */

 sequential_sep   : ';' linebreak
                  | newline_list
                  ;

News to me, but it looks to me like the following is valid:

        for i
        in foo bar baz
        do echo hi
        done

and the following is not:

        for i; in foo bar baz
        do echo hi
        done

2.10.2.6 says the same: all that is allowed between the second word of
a "for" command and the "in" or "do" keyword is a sequence of newlines.

The system 7 bourne shell indeed does not tolerate a ';' before 'do'.
The original ash requires a ';' or newline.

Upshot: while the maximally portable syntax is

        for i
        do ...

POSIX also allows

        for i do ...

and not
        for i; do ...

[1] 
http://www.opengroup.org/onlinepubs/000095399/utilities/xcu_chap02.html#tag_02_10



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to