From 6d7b76115f1e6f033f6e9348e3480ddb11ecde78 Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Tue, 3 Sep 2024 13:00:37 -0400 Subject: [PATCH] use the version that is longest for the loop --- salt/common/tools/sbin/so-common | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/salt/common/tools/sbin/so-common b/salt/common/tools/sbin/so-common index fcc669fe2..8795e6828 100755 --- a/salt/common/tools/sbin/so-common +++ b/salt/common/tools/sbin/so-common @@ -168,7 +168,7 @@ check_salt_minion_status() { return $status } -# compare es versions and return the highest version +# Compare es versions and return the highest version compare_es_versions() { # Save the original IFS local OLD_IFS="$IFS" @@ -179,9 +179,15 @@ compare_es_versions() { # Restore the original IFS IFS="$OLD_IFS" + # Determine the maximum length between the two version arrays + local max_len=${#ver1[@]} + if [[ ${#ver2[@]} -gt $max_len ]]; then + max_len=${#ver2[@]} + fi + # Compare each segment of the versions - for ((i=0; i<${#ver1[@]}; i++)); do - # if a segment in ver1 or ver2 is missing, set it to 0 + for ((i=0; i