Subject: Re: bin/15997: grouping example in sh manual broken?
To: None <reed@reedmedia.net>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 03/21/2002 17:23:48
[ On Thursday, March 21, 2002 at 13:16:11 (-0800), reed@reedmedia.net wrote: ]
> Subject: bin/15997: grouping example in sh manual broken?
>
> The grouping example
>  
>  { echo -n " hello " ; echo " world" } > greeting
> 
> doesn't seem to work from prompt or in sh script.
>    
> The shell doesn't see the closing brace.
>    
> Syntax error: end of file unexpected (expecting "}")
> 
> >Fix:
> 
> I assume shell is broken and man page is correct.

Nope -- the shell is correct.

A correct example (with only the necessary whitespace) would be:

  { echo -n " hello ";echo " world";}>greeting

From SuSv2:

       Grouping Commands                                                        
                                                                                
       The format for grouping commands is as follows:                          

       (compound-list)                                                          

               Execute compound-list in a subshell environment; see
               Shell Execution Environment.  Variable assignments and
               built-in commands that affect the environment will not
               remain in effect after the list finishes.

       { compound-list;}                                                        

               Execute compound-list in the current process environment.
               The semicolon shown here is an example of a control
               operator delimiting the "}" reserved word.  Other
               delimiters are possible, as shown in Shell Grammar; a
               newline character is frequently used.



-- 
								Greg A. Woods

+1 416 218-0098;  <gwoods@acm.org>;  <g.a.woods@ieee.org>;  <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>