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
精彩评论