From f2785eca106c0096b8e64c50b5336771f27f641a Mon Sep 17 00:00:00 2001 From: Jaromil Date: Mon, 26 Dec 2016 12:11:55 +0100 Subject: [PATCH] added small function to compare semantic versions uses sort and head as external deps --- zuper | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/zuper b/zuper index 020fb63..cce80d7 100755 --- a/zuper +++ b/zuper @@ -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