{ and } with for in /bin/sh

Moderator, John S. Quarterman std-unix at longway.TIC.COM
Fri Apr 6 08:35:00 AEST 1990

From: Maarten Litmaath <uunet!cs.vu.nl!maart>

In article <528 at ehviea.ine.philips.nl>,
	leo at ehviea.ine.philips.nl (Leo de Wit) writes:
)The fact that the terminating } has to be preceded by a command
)separator as opposed to the terminating ) where it is not needed, seems
)rather odd to me.  This also goes for the start {, that has to be
)followed by white space to be considered a token, as opposed to the
)start (. Was { } perhaps a 'last minute hack' ?

Whatever, it has the advantage of making the following possible:

	$ echo {1,2,3}{a,b,c}
	1a 1b 1c 2a 2b 2c 3a 3b 3c

In csh this works as demonstrated, in ksh it's a compile-time option.
Regarding the POSIX sh I say: either add this feature or let braces
parse like parentheses.  In the latter case the only difference between
them would be: a parenthesized expression evaluates in a subshell, a braced
expression evaluates in the current shell (*always*, even if the input or
output of the list has been redirected; in current implementations such
redirections cause evaluation in a subshell).
 1) Will 4.5BSD have wait5()?         |Maarten Litmaath @ VU Amsterdam:
 2) Sleep(3) should be sleep(2) again.|maart at cs.vu.nl, uunet!mcsun!botter!maart

Volume-Number: Volume 19, Number 73

More information about the Comp.std.unix mailing list