On Wed, Oct 28, 2009 at 05:31:07PM +0000, Stephane Chazelas wrote:
> $ posh -c 'f() echo test; f'
> test
> 
> Same output for all the other Bourne-like shells but bash.
> 
> $ bash -c 'f() echo test; f'
> bash: -c: line 0: syntax error near unexpected token `echo'
> bash: -c: line 0: `f() echo test; f'
> 
> which makes that construct non-portable even it it's Bourne. So
> posh should return an error as well. POSIX requires a compound
> command for the function body, so the behavior is unspecified if
> a simple command is used instead. From SUSv4:
> 
>  function_definition : fname '(' ')' linebreak function_body
>                   ;
>  function_body    : compound_command                /* Apply rule 9 */
>                   | compound_command redirect_list  /* Apply rule 9 */
> 
> f() (echo test)
> f() { echo test;}
> f() for i in .; do echo test; done
> 
> are allowed, but not:
> 
> f() echo test

I agree with this interpretation.



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to