开发者

Comparing strings in if and using or

This code is not working, but I don't know what's wrong. If I only use single brackets the string isn'开发者_JAVA技巧t compared right.

#!/bin/bash
forceupdate=false
currentVersion=520-19
latestVersion=520-19
if [[ "$latestVersion" > "$currentVersion" -o forceupdate ]]
then
    echo -e "\nupdate!\n"
else
    echo -e "\nno update!\n"
fi


$forceupdate inside brackets will actually be true, because it's not going to execute the false executable, but it will see a non-empty string.

if [[ "$latestVersion" > "$currentVersion" ]] || $forceupdate
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜