Re: Function definition syntax inconsistencies

2008-06-13 Thread Jan Schampera
Chet Ramey wrote: >> - >> $ function name (echo) >> bash: syntax error near unexpected token `echo' >> - > It's not. It's a shift/reduce conflict in the grammar. The default > yacc/bison behavior is to choose the `function word () command'

Re: Function definition syntax inconsistencies

2008-06-13 Thread Chet Ramey
Jan Schampera wrote: When you use the third form shown above and use the subshell-grouping compound command '(...)' as function body, then it doesn't pass the parser: - $ function name (echo) bash: syntax error near unexpected token `echo' ---

Re: Function definition syntax inconsistencies

2008-06-05 Thread Jan Schampera
Thanks for your replies. I didn't want to raise a portability and POSIX discussion. I know about that. I was referring to either a bug in the Bash manual or a bug in the Bash code, nothing else. Let's try to rephrase that a bit (the topic is not POSIX nor portability): The Bash manual allows the

Re: Function definition syntax inconsistencies

2008-06-05 Thread Stephane Chazelas
On Thu, Jun 05, 2008 at 10:07:51AM +0200, Andreas Schwab wrote: > Stephane Chazelas <[EMAIL PROTECTED]> writes: > > > I suspect this: > > $ sh -c 'function() { echo a; }; function' > > sh: -c: line 0: syntax error near unexpected token `(' > > sh: -c: line 0: `function() { echo a; }; function' > >

Re: Function definition syntax inconsistencies

2008-06-05 Thread Andreas Schwab
Stephane Chazelas <[EMAIL PROTECTED]> writes: > I suspect this: > $ sh -c 'function() { echo a; }; function' > sh: -c: line 0: syntax error near unexpected token `(' > sh: -c: line 0: `function() { echo a; }; function' > > breaks POSIX conformance, BTW (but then it's the same for AT&T > ksh, pdksh

Re: Function definition syntax inconsistencies

2008-06-05 Thread Stephane Chazelas
On Thu, Jun 05, 2008 at 06:31:36AM +0200, Jan Schampera wrote: [...] > The function definition is allowed in 3 forms: > 1. NAME() ... That's the Bourne and POSIX syntax > 3. function NAME ... That's the ksh syntax. It's probably only there for compatibility with ksh (note