[TUHS] Use of "{}" in the Shell?
Arnold Robbins via TUHS
tuhs at tuhs.org
Tue Aug 4 20:04:36 AEST 2026
Peter Pentchev <roam at ringlet.net> wrote:
> On Tue, Aug 04, 2026 at 12:47:44AM -0600, Arnold Robbins via TUHS wrote:
> > Warner Losh via TUHS <tuhs at tuhs.org> wrote:
> >
> > > I've not examined the source to Thompson shell closely to know if it
> > > secretly does this (and that's why Steve Bourne implemented it), or if
> > > that's something Bourne invented.
> >
> > Braces are also allowed where "do" and "done" are.
> >
> > I have always suspected, but never bothered to verify, that this is
> > the case so that shell scripts could look more like C if one wanted
> > them to. For example, in Bash:
> >
> > $ for ((i = 1; i <= 3; i++))
> > > {
> > > echo $i
> > > }
> > 1
> > 2
> > 3
>
> Well, that's several kinds of Bash-specific syntax right there :)
> (nothing wrong with that, just pointing it out)
The `for((...))' originated in ksh (ksh 88 I think), but the ability
to use braces instead of do and done goes back to the V7 Bourne shell.
Just sayin'.
Arnold
More information about the TUHS
mailing list