[TUHS] Use of "{}" in the Shell?
David Barto via TUHS
tuhs at tuhs.org
Wed Aug 5 05:23:29 AEST 2026
Then why does
echo me; echo $$
( echo parens ; echo $$ ; )
{ echo brace; echo $$ ; }
Always echo the same pid?
me
46999
parens
46999
brace
46999
> On Aug 3, 2026, at 11:47 PM, Arnold Robbins via TUHS <tuhs at tuhs.org> 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
>
> Arnold
More information about the TUHS
mailing list