Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16729

Re: Undocumented for-loop construct

From worley@alum.mit.edu (Dale R. Worley)
Newsgroups gnu.bash.bug
Subject Re: Undocumented for-loop construct
Date 2020-08-06 22:29 -0400
Message-ID <mailman.1068.1596767403.2739.bug-bash@gnu.org> (permalink)
References <CAGqdar04i1z28vYUFuGr=7WZOUsar8JE+QW0TAm1bnP0+DtEjQ@mail.gmail.com> <87364zur1p.fsf@hobgoblin.ariadne.com>

Show all headers | View raw


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, though I haven't
tried extending while/until and recompiling parse.y; maybe it doesn't
work.

Dale

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


Thread

Re: Undocumented for-loop construct worley@alum.mit.edu (Dale R. Worley) - 2020-08-06 22:29 -0400

csiph-web