From Headcrush, 6 Months ago, written in Bash.
  1. vercomp () {
  2.     if [[ $1 == $2 ]]
  3.     then
  4.         return 0
  5.     fi
  6.     local IFS=.
  7.     local i ver1=($1) ver2=($2)
  8.     # fill empty fields in ver1 with zeros
  9.     for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
  10.     do
  11.         ver1[i]=0
  12.     done
  13.     for ((i=0; i<${#ver1[@]}; i++))
  14.     do
  15.         if [[ -z ${ver2[i]} ]]
  16.         then
  17.             # fill empty fields in ver2 with zeros
  18.             ver2[i]=0
  19.         fi
  20.         if ((10#${ver1[i]} > 10#${ver2[i]}))
  21.         then
  22.             return 1
  23.         fi
  24.         if ((10#${ver1[i]} < 10#${ver2[i]}))
  25.         then
  26.             return 2
  27.         fi
  28.     done
  29.     return 0
  30. }

Replies to sudo_error rss

Title Name Language When
sudo_error_example Headcrush bash 6 Months ago.
captcha