开发者

Comparing strings in if and using or

开发者 https://www.devze.com 2023-03-07 22:12 出处:网络
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.

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

精彩评论

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

关注公众号