我收到此错误:
getengine.sh: line 38: [: =: unary operator expected
getengine.sh: line 41: [: =: unary operator expected
这是脚本:
if [ $1 = "m" ]; then #this is line 38
initial=`curl -s http://some/2016/30-publish`
label=`curl -s http://test/${initial}.l/artifacts/info.xml`
elif [ $1 = "s" ]; then # this is line 41
initial=`curl -s http://some/2016/30-publish`
label=`curl -s http://test/${initial}.l/artifacts/info.xml`
fi
我不明白出了什么问题?这在本地完美运行,但是当我在linux环境服务器中运行时,我收到此错误...任何帮助将不胜感激
答案 0 :(得分:1)
您需要更多报价。
# this is correct
[ "$1" = "m" ]
...不...
# WRONG: this becomes [ = m ] if $1 is empty, producing your error.
[ $1 = "m" ]