bug-bash
[Top][All Lists]
Advanced

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

Re: function grammar


From: Bernd Eggink
Subject: Re: function grammar
Date: Mon, 19 Jul 2010 10:46:30 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.4) Gecko/20100608 Thunderbird/3.1

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."

Bernd

--
Bernd Eggink
http://sudrala.de



reply via email to

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