Created
December 6, 2013 11:33
-
-
Save c9s/7822341 to your computer and use it in GitHub Desktop.
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 | |
# Usage: | |
# | |
# git push origin $(git tag | version_lt 1.7.0 | xargs -I{} echo :{}) | |
# | |
# version_lt 1.6.0 1.7.0 | |
split() | |
{ | |
# Prefix local names with the function name to try to avoid conflicts | |
# local split_wordlist | |
split_wordlist="$1" | |
shift | |
read "$@" <<EOF-split-end-of-arguments | |
${split_wordlist} | |
EOF-split-end-of-arguments | |
} | |
test_version_lt() | |
{ | |
version_ge_v1=$1 | |
version_ge_v2=$2 | |
version_ge_v1=${version_ge_v1/-[a-z]*/} | |
version_ge_v2=${version_ge_v2/-[a-z]*/} | |
version_ge_save_ifs="$IFS" | |
while test -n "${version_ge_v1}${version_ge_v2}"; do | |
IFS="." | |
split "$version_ge_v1" version_ge_a version_ge_v1 | |
split "$version_ge_v2" version_ge_b version_ge_v2 | |
IFS="$version_ge_save_ifs" | |
#echo " compare $version_ge_a $version_ge_b" | |
test "0$version_ge_a" -lt "0$version_ge_b" && echo $1 # v1<v2:false | |
done | |
} | |
if [[ -n $1 && -n $2 ]] ; then | |
test_version_lt $1 $2 | |
else | |
while read source_version ; do | |
test_version_lt $source_version $1 | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment