added small function to compare semantic versions

uses sort and head as external deps
This commit is contained in:
Jaromil 2016-12-26 12:11:55 +01:00
parent 4fed4af700
commit f2785eca10
1 changed files with 6 additions and 0 deletions

6
zuper
View File

@ -531,6 +531,12 @@ s/ /%09/g
'
}
# Check if a version number (semantic format) is greater than the other
# returns 0 if the first argument is greater or equal than the second.
function string.version_greatoreq version_greatoreq() {
[[ "$(printf '%s\n' "$@" | sort -rV | head -n 1)" = "$1" ]] && return 0
return 1
}
# }}} Strings