[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function definition syntax inconsistencies

From: Chet Ramey
Subject: Re: Function definition syntax inconsistencies
Date: Fri, 13 Jun 2008 18:12:29 -0400
User-agent: Thunderbird (Macintosh/20080421)

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'

That's the reason I think there's a bug, either in the description or in
the code. Since the rest of the behaviour of function definitions is
very consistent as described in the manual, I assume it's a bug in the code.

It's not.  It's a shift/reduce conflict in the grammar.  The default
yacc/bison behavior is to choose the `function word () command' production,
and I have left it that way.  The `function word command' form came from
ksh, which doesn't allow the construct you used anyway (it requires one
or more newlines after the word), so the current bash implementation
supports all existing ksh uses.

``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]