+# Version compare functions
+vercomp () {
+ set +u
+ if [[ "$1" == "$2" ]]; then
+ return 0
+ fi
+ local IFS=.
+ local i ver1=($1) ver2=($2)
+ # fill empty fields in ver1 with zeros
+ for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
+ ver1[i]=0
+ done
+ for ((i=0; i<${#ver1[@]}; i++)); do
+ if [[ -z ${ver2[i]} ]]; then
+ # fill empty fields in ver2 with zeros
+ ver2[i]=0
+ fi
+ if ((10#${ver1[i]} > 10#${ver2[i]})); then
+ return 1
+ fi
+ if ((10#${ver1[i]} < 10#${ver2[i]})); then
+ return 2
+ fi
+ done
+ set -u
+ return 0
+}
+
+verlte() {
+ vercomp "$1" "$2"; local res="$?"
+ [ "$res" -eq "0" ] || [ "$res" -eq "2" ]
+}
+
+verlt() {
+ vercomp "$1" "$2"; local res="$?"
+ [ "$res" -eq "2" ]
+}
+
+vergte() {
+ vercomp "$1" "$2"; local res="$?"
+ [ "$res" -eq "0" ] || [ "$res" -eq "1" ]
+}
+
+vergt() {
+ vercomp "$1" "$2"; local res="$?"
+ [ "$res" -eq "1" ]
+}
+
+verne() {
+ vercomp "$1" "$2"; local res="$?"
+ [ "$res" -ne "0" ]
+}
+