3
定义功能我已经看到函数中定义的.bashrc两种方式:差异在bash
dosomething() { ... }
和
function dosomething() { ... }
这有什么区别使用function
声明?
定义功能我已经看到函数中定义的.bashrc两种方式:差异在bash
dosomething() { ... }
和
function dosomething() { ... }
这有什么区别使用function
声明?
http://www.gnu.org/s/bash/manual/bash.html#Shell-Functions
功能都采用这种语法声明:
[ function ] name() compound-command [ redirections ]
定义一个shell函数命名的名称。 保留字的功能是 可选。如果提供功能保留字,则括号 是可选的。
function
并省略括号是特定于bash的。所以为了更便携,不要使用它。
清除,谢谢。 – Strapakowsky
我正在使用一个使用函数关键字的函数库,它搞砸了我的/ etc/hosts。这是因为我使用的bash shell没有使用function关键字。这是在Ubuntu 13.注意这些脚本。 – CMCDragonkai