This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# compare version $1 and $2; returns 0 if version $1 >= $2 | |
# versions must be numeric only | |
vcompare() { | |
local v1=$1 v2=$2 v1a v2a n1 n2 max i | |
IFS=. read -ra v1a <<< "$v1"; IFS=. read -ra v2a <<< "$v2" | |
((n1=${#v1a[@]}, n2=${#v2a[@]}, max=(n1 > n2 ? n1 : n2))) | |
for ((i=0; i<max; ++i)) | |
do |