如果腳本有「」,爲什麼bash的行爲如此?
if [ $1 == "-?" ]; then #line 4
echo "usage: ...."
fi
當腳本獲取運行不帶任何參數,它會抱怨
./script.sh: line 4: [: ==: unary operator expected
但如果不是
if [ "$1" == "-?" ]; then #line 4
echo "usage: ...."
fi
然後一切都很好
這是爲什麼?
感謝