safer version number array building

This commit is contained in:
Lance Vick 2020-11-19 23:41:53 -08:00
parent 72710638f6
commit 8f85f0b9e5
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
1 changed files with 4 additions and 3 deletions

7
sig
View File

@ -1,7 +1,7 @@
#! /usr/bin/env bash #! /usr/bin/env bash
set -e set -e
readonly MIN_BASH_VERSION=4 readonly MIN_BASH_VERSION=5
readonly MIN_GPG_VERSION=2.2 readonly MIN_GPG_VERSION=2.2
readonly MIN_OPENSSL_VERSION=1.1 readonly MIN_OPENSSL_VERSION=1.1
readonly MIN_GETOPT_VERSION=2.33 readonly MIN_GETOPT_VERSION=2.33
@ -71,9 +71,10 @@ check_version(){
local pkg="${1?}" local pkg="${1?}"
local have="${2?}" local have="${2?}"
local need="${3?}" local need="${3?}"
local i ver1 ver2 IFS='.'
[[ "$have" == "$need" ]] && return 0 [[ "$have" == "$need" ]] && return 0
local IFS=. read -r -a ver1 <<< "$have"
local i ver1=($have) ver2=($need) read -r -a ver2 <<< "$need"
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); for ((i=${#ver1[@]}; i<${#ver2[@]}; i++));
do ver1[i]=0; do ver1[i]=0;
done done