From: Roman Cheplyaka on
According to formal shell grammar http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
the "for" clause is defined by following productions:

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

As can be seen from them, if there is no "in" reserved word, there can
be no sequential_sep before do_group.
However, all available to me shells (ksh, bash, dash, posh) accept
both forms:
for i do echo $i; done
for i; do echo $i; done

Are they all wrong or I missed something?
From: Stephane CHAZELAS on
2010-03-12, 23:25(-08), Roman Cheplyaka:
> According to formal shell grammar http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
> the "for" clause is defined by following productions:
>
> for_clause : For name linebreak
> do_group
> | For name linebreak in sequential_sep
> do_group
> | For name linebreak in wordlist sequential_sep
> do_group
>
> As can be seen from them, if there is no "in" reserved word, there can
> be no sequential_sep before do_group.
> However, all available to me shells (ksh, bash, dash, posh) accept
> both forms:
> for i do echo $i; done
> for i; do echo $i; done
>
> Are they all wrong or I missed something?

FWIW, the Bourne shell (a non-POSIX shell, but POSIX shells
descend from it) doesn't support the latter.

Note that it's a a bug in posh if it supports it, it should be
reported. But not in the other shells. POSIX doesn't prevent
shell implementations from supporting it, but script writers
from using it.

posh was created as a tool to help script authors to write
compliant scripts, so it should report an error on
non-conformant syntax.

--
Stéphane
From: Roman Cheplyaka on
On Mar 13, 11:46 am, Stephane CHAZELAS <stephane_chaze...(a)yahoo.fr>
wrote:
> 2010-03-12, 23:25(-08), Roman Cheplyaka:
>
>
>
> > According to formal shell grammarhttp://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
> > the "for" clause is defined by following productions:
>
> > for_clause       : For name linebreak
> > do_group
> >                  | For name linebreak in          sequential_sep
> > do_group
> >                  | For name linebreak in wordlist sequential_sep
> > do_group
>
> > As can be seen from them, if there is no "in" reserved word, there can
> > be no sequential_sep before do_group.
> > However, all available to me shells (ksh, bash, dash, posh) accept
> > both forms:
> > for i do echo $i; done
> > for i; do echo $i; done
>
> > Are they all wrong or I missed something?
>
> FWIW, the Bourne shell (a non-POSIX shell, but POSIX shells
> descend from it) doesn't support the latter.
>
> Note that it's a a bug in posh if it supports it, it should be
> reported. But not in the other shells. POSIX doesn't prevent
> shell implementations from supporting it, but script writers
> from using it.
>
> posh was created as a tool to help script authors to write
> compliant scripts, so it should report an error on
> non-conformant syntax.

Didn't know that. From debian package description: "posh is a stripped-
down version of pdksh that aims for compliance with Debian's policy,
and few extra features." And I didn't find any homepage besides Debian
git repository.

The original question (and similar questions earlier in this
newsgroup) comes from my attempt to write such a tool, loker (http://
github.com/feuerbach/loker). I take standards compliance for serious,
that's why I need to know which behaviour is correct one.