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'
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'
---
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
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'
> >
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
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
Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash