title: Alternative for-loop construct
body: <p><strong>General comment:</strong> any new answer which gives a new and useful insight into this question will be rewarded with a bonus.</p>
  <hr />
  <p>The <a href="https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html" rel="noreferrer">Bash reference manual</a> mentions that Bash supports the
  following for-loop constructs:</p>
  <pre><code>for name [ [in [words ...] ] ; ] do commands; done
  for (( expr1 ; expr2 ; expr3 )) ; do commands ; done
  </code></pre>
  <p>Surprisingly, the following for-loop constructs are also valid:</p>
  <pre><code>for i in 1 2 3; { echo $i; }
  for ((i=1;i&lt;=3;++i)); { echo $i; }
  </code></pre>
  <p>These unusual constructs are not documented at all. Neither the <a href="https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html" rel="noreferrer">Bash
  manual</a>, the <a href="https://linux.die.net/man/1/bash" rel="noreferrer">Bash man-pages</a> nor <a href="https://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html#sect_09_01" rel="noreferrer">The Linux Documentation
  Project</a> make any mention of these constructs.</p>
  <p>When investigating the <a href="https://git.savannah.gnu.org/cgit/bash.git/tree/parse.y?h=bash-5.0#n805" rel="noreferrer">language grammar</a> one can see that using
  open-and-close braces (<code>{ commands; }</code>) as an alternative to <code>do commands; done</code> is a valid construct that is implemented for both
  for-loops and select statements and dates back to <a href="https://ftp.gnu.org/gnu/bash/" rel="noreferrer">Bash-1.14.7</a>
  <sup>[1]</sup>.</p>
  <p>The other two loop-constructs:</p>
  <pre><code>until test-commands; do consequent-commands; done
  while test-commands; do consequent-commands; done
  </code></pre>
  <p>do not have this alternative form.</p>
  <hr />
  <p>Since a lot of shell-languages are related, one can find that these
  constructs are also defined there and mildly documented. The <a href="http://man.openbsd.org/ksh" rel="noreferrer">KSH manual</a> mentions:</p>
  <blockquote>
  <p>For historical reasons, open and close braces may be used instead of <code>do</code> and <code>done</code> e.g.</p>
  <pre><code>for i; { echo $i; } 
  </code></pre>
  </blockquote>
  <p>while ZSH implements and <a href="http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html#Alternate-Forms-For-Complex-Commands" rel="noreferrer">documents</a> similar alternatives for the other loop-constructs, but with limitations. It states:</p>
  <blockquote>
  <p>For the <code>if</code>, <code>while</code> and <code>until</code> commands, in both these cases the
  test part of the loop must also be suitably delimited, such as by
  <code>[[ ... ]]</code> or <code>(( ... ))</code>, else the end of the test will not be recognized.</p>
  </blockquote>
  <hr />
  <p><strong>Question:</strong> What is the origin of this construct and why is
  this not propagated to the other loop-constructs?</p>
  <hr />
  <p><strong>Update 1:</strong> There are some very <a href="https://stackoverflow.com/questions/63247449/alternate-for-loop-construct#comment111847043_63247449">useful</a> and <a href="https://stackoverflow.com/questions/63247449/alternate-for-loop-construct#comment111901747_63247449">educational</a> comments below
  this post pointing out that this is an undocumented Bourne Shell feature which seems to be the result of a C-vs-sh language battle in the early days.</p>
  <hr />
  <p><strong>Update 2:</strong> When asking the question: <em>Why is this language feature not documented?</em> to the <a href="https://lists.gnu.org/archive/html/bug-bash/2020-08/msg00058.html" rel="noreferrer">Gnu Bash mailinglist</a>, I received the following answer from Chet Ramey (current lead-developer of GNU bash):</p>
  <blockquote>
  <p>It's never been documented. The reason bash supports it (undocumented) is
  because it was an undocumented Bourne shell feature that we implemented
  for compatibility. At the time, 30+ years ago, there were scripts that used
  it. I hope those scripts have gone into the dustbin of history, but who
  knows how many are using this construct now.</p>
  <p>I'm going to leave it undocumented; people should not be using it anyway.</p>
  </blockquote>
  <hr />
  <p><strong>Related questions/answers:</strong></p>
  <ul>
  <li><a href="https://stackoverflow.com/q/22619510/8344060">A bash loop with braces?</a></li>
  <li><a href="https://stackoverflow.com/q/211378/8344060">Hidden features of Bash</a> (<a href="https://stackoverflow.com/a/8870060/8344060">this answer</a>)</li>
  <li><a href="https://unix.stackexchange.com/q/306940/273492">[U&amp;L] What is the purpose of the “do” keyword in Bash for loops?</a></li>
  </ul>
  <hr />
  <p><sub><strong>Footnotes:</strong> <sup>[1]</sup> I did not find earlier versions, I do believe it predates this</sub></p>