我在bash困惑這個表達式:猛砸,對於不同的文件測試(測試-f)混亂的結果
$ var="" # empty var
$ test -f $var; echo $? # test if such file exists
0 # and this file exists, amazing!
$ test -f ""; echo $? # let's try doing it without var
1 # and all ok
我無法理解這樣的bash的行爲,也許有人能解釋一下嗎?
我可以確認在Centos 6下,我可以複製這個。 – 2012-08-01 13:59:09
不是shell或測試中的錯誤。只是在你的期望錯誤:-) – Jens 2012-08-01 14:04:01