Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > gnu.bash.bug > #16730

Re: Undocumented for-loop construct

From Lawrence Velázquez <vq@larryv.me>
Newsgroups gnu.bash.bug
Subject Re: Undocumented for-loop construct
Date 2020-08-06 22:42 -0400
Message-ID <mailman.1069.1596768176.2739.bug-bash@gnu.org> (permalink)
References <87364zur1p.fsf@hobgoblin.ariadne.com> <EE275E52-B44A-4033-A7DE-A5D8FAE4A954@larryv.me>

Show all headers | View raw


> On Aug 6, 2020, at 10:29 PM, Dale R. Worley <worley@alum.mit.edu> wrote:
> 
> Klaas Vantournhout <klaas.vantournhout@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.  Not clear why that would be

Unless I'm quite mistaken, our very own Oğuz left the only answer
on the OP's Stack Overflow question, explaining that braced forms
of the other compound commands would be syntactically ambiguous.

https://stackoverflow.com/a/63261064

vq

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Undocumented for-loop construct Lawrence Velázquez <vq@larryv.me> - 2020-08-06 22:42 -0400

csiph-web