From 01e3728d8430d0713421f8efbbe574ae13b1c381 Mon Sep 17 00:00:00 2001 From: Timothe Litt Date: Thu, 2 Sep 2021 10:01:44 -0400 Subject: [PATCH] Compare version numbers properly getssl uses cURL's version to determine what command options are valid. The previous shortcuts will fail when curl V8.10 is released. (8.9 is greater than 8.10). V8 is planned for release, in part to avoid a minor version of 100, which also would fail. check_version() will compare full or partial version strings by component, and is true if $1 is at least $2. --- getssl | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/getssl b/getssl index f7a58b9..c8dfde7 100755 --- a/getssl +++ b/getssl @@ -269,6 +269,7 @@ # 2021-07-30 Prefer API V2 when both offered (tlhackque) (#690) (2.40) # 2021-07-30 Run tests with -d to catch intermittent failures, Use fork's repo for upgrade tests. (tlhackque) (#692) (2.41) # 2021-08-26 Improve upgrade check & make upgrade do a full install when possible (tlhackque) (#694) (2.42) +# 2021-09-02 Fix version compare - cURL v8 may have single digit minor numbers. (tlhackque) (2.43) # ---------------------------------------------------------------------------------------- case :$SHELLOPTS: in @@ -277,7 +278,7 @@ esac PROGNAME=${0##*/} PROGDIR="$(cd "$(dirname "$0")" || exit; pwd -P;)" -VERSION="2.42" +VERSION="2.43" # defaults ACCOUNT_KEY_LENGTH=4096 @@ -924,6 +925,27 @@ check_getssl_upgrade() { # check if a more recent release is available graceful_exit } +check_version() { # true if version string $1 >= $2 + local v1 v2 i n1 n2 n + # $1 and $2 can be different lengths, but all parts must be numeric + if [[ "$1" == "$2" ]] ; then return 0; fi + local IFS='.' + # shellcheck disable=SC2206 + v1=($1) + # shellcheck disable=SC2206 + v2=($2) + n1="${#v1[@]}" + n2="${#v2[@]}" + if [[ "$n1" -ge "$n2" ]] ; then n="$n1" ; else n="$n2" ; fi + for ((i=0; i