开发者

Difference in defining function in bash

I have seen function defined two ways in bashrc:

dosomething() { ... } 

and

开发者_Go百科function dosomething() { ... } 

What difference does it make to use the function declaration?


http://www.gnu.org/s/bash/manual/bash.html#Shell-Functions

Functions are declared using this syntax:

 [ function ] name () compound-command [ redirections ]

This defines a shell function named name. The reserved word function is optional. If the function reserved word is supplied, the parentheses are optional.

function and omitting parentheses is bash-specific. So to be more portable, don't use it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜