From 64c32bca07d5f0461f420721c5953acd278b54e3 Mon Sep 17 00:00:00 2001 From: deajan Date: Thu, 20 Apr 2017 21:24:04 +0200 Subject: [PATCH] Update ofunctions --- dev/ofunctions.sh | 66 +++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/dev/ofunctions.sh b/dev/ofunctions.sh index dbefab2..048aaf6 100644 --- a/dev/ofunctions.sh +++ b/dev/ofunctions.sh @@ -3,7 +3,7 @@ #### OFUNCTIONS MINI SUBSET #### _OFUNCTIONS_VERSION=2.1.1 -_OFUNCTIONS_BUILD=2017041001 +_OFUNCTIONS_BUILD=2017041101 #### _OFUNCTIONS_BOOTSTRAP SUBSET #### _OFUNCTIONS_BOOTSTRAP=true #### _OFUNCTIONS_BOOTSTRAP SUBSET END #### @@ -1833,38 +1833,42 @@ function ParentPid { # Neat version compare function found at http://stackoverflow.com/a/4025065/2635443 # Returns 0 if equal, 1 if $1 > $2 and 2 if $1 < $2 function VerComp () { - local result + if [ "$1" == "" ] || [ "$2" == "" ]; then + Logger "Bogus Vercomp values [$1] and [$2]." "WARN" + return 1 + fi - if [[ $1 == $2 ]] - then - echo 0 - return - 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 - echo 1 + if [[ $1 == $2 ]] + then + echo 0 return - fi - if ((10#${ver1[i]} < 10#${ver2[i]})) - then - echo 2 - return - fi - done + 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 + echo 1 + return + fi + if ((10#${ver1[i]} < 10#${ver2[i]})) + then + echo 2 + return + fi + done echo 0 return