Skip to content

helpers/common.sh: the minimal version is Bash 5.0

Karel Koci requested to merge hotfix/bash-min into hbk

The syntax used in the Bash scripts here requires at minimum Bash 5.0. This checks for it and reports reasonable error message instead of failure.

There are two discovered issues with older versions of bash.

The first issue is the change of empty array expansion in Bash 4.4 resulted in empty arrays not being considered as undefined anymore. We depended on this heavily and thus we can't easily go bellow that version.

The second issue is that syntax [[ -v "foo[key]" ] works only in Bash 5.0 and newer. This checks if specific key is in the associative array. The replacement could be [ "${foo[key]:+_}" ] in some cases but this only works if value is also nonempty. Thus it makes sense to just the more clear and reliable syntax and such depend on Bash 5.0.

Merge request reports