Last active
January 7, 2022 22:59
-
-
Save konsolebox/089298db3c19911d5d342f6b7e562cc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function compare_versions { | |
local a=${1%%.*} b=${2%%.*} | |
[[ "10#${a:-0}" -gt "10#${b:-0}" ]] && return 1 | |
[[ "10#${a:-0}" -lt "10#${b:-0}" ]] && return 2 | |
a=${1:${#a} + 1} b=${2:${#b} + 1} | |
[[ -z $a && -z $b ]] || compare_versions "$a" "$b" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment