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

Chet Ramey via TUHS tuhs at tuhs.org
Thu Aug 6 00:08:40 AEST 2026


On 8/4/26 4:21 AM, Peter Pentchev via TUHS 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)

Only one: the arithmetic `for' loop. This works fine in the v7 shell:

for f in 1 2 3
{
	echo $f
}

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet at case.edu    http://tiswww.cwru.edu/~chet/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: OpenPGP digital signature
URL: <http://www.tuhs.org/pipermail/tuhs/attachments/20260805/5f034f41/attachment.sig>


More information about the TUHS mailing list