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.
精彩评论