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

Peter Pentchev via TUHS tuhs at tuhs.org
Tue Aug 4 09:23:54 AEST 2026


On Tue, Aug 04, 2026 at 02:09:22AM +0300, Peter Pentchev wrote:
> On Tue, Aug 04, 2026 at 08:24:57AM +1000, Dave Horsfall via TUHS 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 should work on pretty much any Bourne-compatible shell, I think.
> However, there is one crucial point: you *must* place a semicolon between
> the last command and the closing brace, and if you write commands on
> the same line, you also *must* place a semicolon between the closing
> brace and the next command :)

And of course, I forgot to include an actually useful example:
something that was pretty common back when I wrote Makefiles for fun:

  gzip -cn9 repopush.1 > repopush.1.gz || { rm -f repopush.1.gz; exit 1; }

G'luck,
Peter

-- 
Peter Pentchev  roam at ringlet.net roam at debian.org peter at morpheusly.com
PGP key:        https://www.ringlet.net/roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://www.tuhs.org/pipermail/tuhs/attachments/20260804/0cc43a24/attachment.sig>


More information about the TUHS mailing list