vendredi 29 mars 2019

If Statement In Bash With Variable

I am trying to check if a remote version is greater than a local version with variables and if statements.

But, so far the variables echo the correct version but even if the remote version is greater than a local version nothing happens with the if statement, what am i doing wrong.

Thanks

lversion_notepadqq() {
    notepadqq -v
}

rmersion_notepadqq() {
    curl -s https://api.github.com/repos/notepadqq/notepadqq/releases | grep tag_name | cut -d \" -f 4 | grep v| tr -d 'v,' | head -1
}

Remote=$(curl -s https://api.github.com/repos/notepadqq/notepadqq/releases | grep tag_name | cut -d \" -f 4 | grep v| tr -d 'v,' | head -1)
Local=$(notepadqq -v)
echo Local Version: $Local
echo Remote Version: $Remote

if (( rmersion_notepadqq > lversion_notepadqq )); then 
    echo Updating && Update_Notepadqq
else
    echo No Update Needed
fi

#Neither if statement seems to work

if (( $Remote > $Local )); then 
    echo Updating && Update_Notepadqq
else
    echo No Update Needed
fi

Aucun commentaire:

Enregistrer un commentaire