0
似乎無法理解以下代碼片段的輸出。試圖在循環中打印函數的返回值在循環shell腳本中獲取函數的返回值
contains() {
local e
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
return 1
}
line="ayush"
line2="this is a line containing ayush"
contains $line $line2
echo $? #prints 0
for i in 1 2 3;do
contains "$line" "$line2"
echo $? #prints 1 everytime
done