On Mon, Jul 19, 2010 at 10:46:30AM +0200, Bernd Eggink wrote:
> Am 19.07.2010 08:30, schrieb Ken Irving:
> >On Sun, Jul 18, 2010 at 11:53:02AM -0700, Linda Walsh wrote:
> >>
> >>from man bash, to define a function use;
> >>
> >>"function" "name"<compound-command>
> >> OR
> >>"name" ()<compound-command>
> >>
> >>right?
> >>
> >>And Compound Commands are:
> >>
> >> (<list>)
> >> {<list>; )
> >> (( expression ))
> >> [[ expression ]]
> >>...et al....
> >>
> >>so why do I get a syntax error for
> >>
> >>function good_dir [[ -n $1&& -d $1&& -r $1&& -x $1 ]]
> >>
> >>bash: syntax error near unexpected token `[['
> >
> >I see this in bash(1):
> >
> > SHELL GRAMMAR
> > ...
> > Shell Function Definitions
> > ...
> > [ function ] name () compound-command [redirection]
> >
> >and do not see the version you show without the parens.
>
> It's there. Look at the 3rd sentence:
>
> "If the function reserved word is supplied, the parentheses are
> optional."
So maybe the declaration could be fixed to show that, e.g., as either of:
name () compound-command [redirection]
function name [()] compound-command [redirection]
I can't see how to put that in one construct...
Ken