开发者

Difference in defining function in bash

开发者 https://www.devze.com 2023-04-01 03:32 出处:网络
I have seen function defined two ways in bashrc: dosomething() { ... } and 开发者_Go百科function dosomething() { ... }

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

精彩评论

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

关注公众号