[TUHS] Use of "{}" in the Shell?
Warner Losh via TUHS
tuhs at tuhs.org
Tue Aug 4 09:34:54 AEST 2026
On Mon, Aug 3, 2026 at 4:25 PM Dave Horsfall via TUHS <tuhs at tuhs.org> wrote:
> A long time ago, in a Unix manpage far away, I saw a reference to "{}"
> which acted similar to "()" except that it did not fork e.g. "{exit}" would
> do just that :-)
>
> Does anyone know the provenance of this Shell? I can't seem to reproduce
> it on the MacBook or the FreeBSD box here (my Penguin box is currently
> dead).
>
It dates back to V7. It's in FreeBSD today. I use it all the time. From
the 7th edition man page:
...
( list )
Execute list in a subshell.
{ list }
list is simply executed.
...
A huge number of shell scripts depend on this behavior. Since the 6th
Edition used the Thompson Shell, it doesn't have this as far as I can tell,
but does have () grouping. 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. But there are '('
and ')' in sh.c, but no '{' or '}', so that leans towards Bourne inventing
it or borrowing it.
Warner
More information about the TUHS
mailing list