Path: utzoo!attcan!uunet!mcvax!philmds!leo
From: leo@philmds.UUCP (Leo de Wit)
Newsgroups: comp.unix.questions
Subject: Re: what's the use of "{ list }" in /bin/sh?
Message-ID: <556@philmds.UUCP>
Date: 8 Jul 88 04:22:25 GMT
References: <23590@teknowledge-vaxc.ARPA> <3305@palo-alto.DEC.COM> <12334@mimsy.UUCP>
Reply-To: leo@philmds.UUCP (Leo de Wit)
Organization: Philips I&E DTS Eindhoven
Lines: 40

In article <12334@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
>In article <3305@palo-alto.DEC.COM> vixie@palo-alto.DEC.COM (Paul Vixie)
>writes various examples (deleted), then:
>>Summary: {list} is useful if you go southpaw with it.  Other than
>>that it seems useless and I can't imagine why it exists.
>
>Actually, it has one more use:
>
>	while { setup; test } do ...
>
>or any other place where a compound statement is needed and only
>a single statement is allowed.  (while and until are about it!)

Actually, the while keyword is followed by a command-list (according to
'An Introduction to the UNIX Shell' by S.R.Bourne, Appendix A - Grammar).

So you CAN write:

	while setup; test; do ...

And, as I pointed out in an other posting, the '}' cannot be used as a
command separator/terminator (while ')' can). So there should be a ; or
newline after test.

Another use of {} could be redirection:
     { echo This is file_a with header; cat file_a; } > file_a_hdr

Of course this can be done with () too; I don't know whether this
involves an extra sh being forked (I mean a sh more than with {}) in
this special case.

Note {} has another quirk: the '{' has to followed by white space or it
will be interpreted as part of the following word (and sh says:
syntax error:`}' unexpected).

And some American reader could perhaps tell me what Paul Vixie meant by
'to go southpaw' (probably American slang?) - although I realize that
this will keep my mailbox quite filled the next few weeks 8-).

       Leo.