Skip to content

Instantly share code, notes, and snippets.

@konsolebox
Last active January 7, 2022 22:59
Show Gist options
  • Save konsolebox/089298db3c19911d5d342f6b7e562cc4 to your computer and use it in GitHub Desktop.
Save konsolebox/089298db3c19911d5d342f6b7e562cc4 to your computer and use it in GitHub Desktop.
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