我有一個bash sourcedbash.sh在另一個bash的主代碼main.sh來源。
運行main.sh與 「集-u」 選項,我得到一個錯誤比我想不通:慶典調試使用set -u
Error /sourced_bash.sh : line xx : variable without link
main.sh
. sourced_bash.sh
my_function $foomain 1
sourcedbash.sh
function my_function(){
local foo=$1
local bar=$2
if [[ 1 -eq $bar ]];then # <= this is LINE xx generating the error
# ... dothis
return 1
elif [[ 0 -eq $bar ]];then
# ... dothat
return 0
fi
}
看着手冊頁和閱讀「我的朋友」沒有坦率的成功。
我需要了解爲什麼「集-u」意味着main.sh程序吸收以及如何擺脫這種錯誤(Debian的萊尼)的。
Thx預先
foomain實際上是5個字符串,根據「dothis」或「dothat」中的大小寫情況而有所不同,但錯誤指出「bar」上的測試行。 – hornetbzz 2011-03-23 16:52:38