Is it [in Unix Version 7] a bug? - I suppose we'd need some old
(original) Bourne shell to test its behavior. - If it would work
in that old shell it could be considered an implementation error
in the clone. Code like i=5 ; while echo $i ; let i=i-1 ; done
would work. Anyway. Being curious I had a peek into the C source
code and (as far as I understood the macro'ized C code correctly)
the while statement expects a 'do' and a 'done'. A comment at the
beginning lists as an "item": "for ... while ... do ... done" ,
a syntax that resembles the Algol 68 generalized loop; which may
(as far as I can tell) be defined formally like
[ for v ] [ from f ] [ by b ] [ to t ] [ while w ] do s od
where almost everything is optional but the 'do' part. Despite
the Algol like "item" in Bourne shell 'for' and 'while' seem to
be separate commands (as we also know from the shell successors).
Interestingly I noticed that the 'for' loop does not seem to need
'do' and 'done'; these can be replaced by braces! - And that is
obviously still supported by some of the modern shells (ksh, zsh,
bash, but not, e.g., by ash):
$ for i in a b ; { echo $i ; }
a
b
(though this seems undocumented). - Funny anyway, and new to me.
Janis