Avoid array subscript error when checking OpenSSL versions

If none of Homebrew OpenSSL versions satisfy the `needs_openssl` requirement,
array iteration will reach `index=-1` and that will raise a non-fatal error
when accessing the `versions` array. This makes sure not to go past index=0.
This commit is contained in:
Mislav Marohnić 2024-11-05 14:42:53 +01:00
parent 281e598b07
commit bc88537fc5
No known key found for this signature in database

View file

@ -1154,7 +1154,7 @@ needs_openssl() {
# shellcheck disable=SC2207
versions=( $(awk '{print $2}' <<<"$brew_installs" | sort_versions) )
local index="${#versions[@]}"
while [ $((index--)) -ge 0 ]; do
while [ $((--index)) -ge 0 ]; do
homebrew_version="$(normalize_semver "${versions[index]}")"
(( homebrew_version >= lower_bound && homebrew_version < upper_bound )) || continue
while read -r formula version prefix; do