[TUHS] Use of "{}" in the Shell?

Arnold Robbins via TUHS tuhs at tuhs.org
Tue Aug 4 16:47:44 AEST 2026


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

Arnold


More information about the TUHS mailing list