Skip to content
Snippets Groups Projects
Verified Commit 3c0b053f authored by Karel Koci's avatar Karel Koci :metal: Committed by Simon Borek
Browse files

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

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.
parent 0d974237
Branches
Tags
1 merge request!503helpers/common.sh: the minimal version is Bash 5.0
Pipeline #97689 passed with stage
in 6 minutes
......@@ -14,7 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
set -eu
# Step list that is run when no commands are specified
DEFAULT_STEPS=( "prepare" "compile" "sign" "store_hash" "stats" "pkgsrepo" "gen_junit" )
......
......@@ -14,7 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
set -eu
FEED_NAME="updater-lists"
......
......@@ -14,6 +14,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
[[ "${BASH_VERSINFO[0]}" -ge 5 ]] || {
echo "Please use Bash version 5.0 or newer!" >&2
exit 1
}
## Common printing functions ############
# Detect tty if IS_TTY not already set
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment