On 8/6/20 10:29 PM, Dale R. Worley wrote: > Klaas Vantournhout <klaas.vantournh...@gmail.com> writes: >> Recently I came across a surprising undocumented bash-feature >> >> $ for i in 1 2 3; { echo $i; }; >> >> The usage of curly-braces instead of the well-documented do ... done >> construct was a complete surprise to me and even lead me to open the >> following question on stack overflow: > > Interesting! Looking at parse.y, it looks like do ... done can be > replaced with { ... } in 'for' and 'select' statements, but not 'while' > and 'until' statements.
The `select' syntax is enough like `for' -- practically identical from a grammar perspective -- that it made sense to support it in `select'. The fact that the Korn shell supports braces in `select' made it a compatibility issue as well. Not clear why that would be, though I haven't > tried extending while/until and recompiling parse.y; maybe it doesn't > work. Because there's a difference between a `list' (for and select) and a `command list' (while and until). If you don't want ambiguous constructs, you nee a reserved word to separate the test command from the body command. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/