rac@sherpa.UUCP (Roger Cornelius) (03/23/90)
I recently came across some sh code which uses { and } instead of do ... done in a for loop. I've never seen this documented in any sh or ksh man page, so should it therefore be considered non-portable? When was this introduced and why isn't it documented? -- Roger A. Cornelius rac@sherpa uunet!sherpa!rac
gwyn@smoke.BRL.MIL (Doug Gwyn) (03/25/90)
In article <237@sherpa.UUCP> rac@sherpa.UUCP (Roger Cornelius) writes:
-I recently came across some sh code which uses { and } instead of
-do ... done in a for loop. I've never seen this documented in any sh
-or ksh man page, so should it therefore be considered non-portable?
-When was this introduced and why isn't it documented?
It IS documented. So far as I can tell it's supported by all Bourne
shells.
dce@smsc.sony.com (David Elliott) (03/27/90)
In article <12430@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >In article <237@sherpa.UUCP> rac@sherpa.UUCP (Roger Cornelius) writes: >-I recently came across some sh code which uses { and } instead of >-do ... done in a for loop. > >It IS documented. So far as I can tell it's supported by all Bourne >shells. It's also documented that { and } work with case, though I haven't gotten into that habit yet (I've used it with for loops for about 6 years). The question I have is why it doesn't also work with while, until, and if/then/else? Maybe people wouldn't think of sh as "the Algol shell" if it were consistent on this point. ;-) -- David Elliott dce@smsc.sony.com | ...!{uunet,mips}!sonyusa!dce (408)944-4073 Help!!! The Easter Bunny is after me!!!
maart@cs.vu.nl (Maarten Litmaath) (04/06/90)
In article <528@ehviea.ine.philips.nl>, leo@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@cs.vu.nl, uunet!mcsun!botter!maart