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