From 58587233af886779f5160c658b4d65707ae3e038 Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Tue, 12 Oct 2021 10:33:16 +0200 Subject: [PATCH] Fix comparision of docker versions In some shells the comparable string with version was too long. The number leading with 0 was interpreted as octal number and it had too many digits for octal number to handle. This change; 1) decreases the length of the string by using 3-digit numbers 2) strips leading 0s during comparision making comparision work in decimal --- scripts/ci/libraries/_initialization.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/ci/libraries/_initialization.sh b/scripts/ci/libraries/_initialization.sh index 31e17e45131fd..ee0d26e474ba0 100644 --- a/scripts/ci/libraries/_initialization.sh +++ b/scripts/ci/libraries/_initialization.sh @@ -929,7 +929,7 @@ function initialization::ga_env() { function initialization::ver() { # convert SemVer number to comparable string (strips pre-release version) # shellcheck disable=SC2086,SC2183 - printf "%04d%04d%04d%.0s" ${1//[.-]/ } + printf "%03d%03d%03d%.0s" ${1//[.-]/} } function initialization::check_docker_version() { @@ -947,7 +947,8 @@ function initialization::check_docker_version() { local min_docker_version="20.10.0" local min_comparable_docker_version min_comparable_docker_version=$(initialization::ver "${min_docker_version}") - if (( comparable_docker_version < min_comparable_docker_version )); then + # The #0 Strips leading zeros + if [[ ${comparable_docker_version#0} -lt ${min_comparable_docker_version#0} ]]; then echo echo "${COLOR_RED}Your version of docker is too old: ${docker_version}. Please upgrade to at least ${min_docker_version}.${COLOR_RESET}" echo