diff --git a/init/eessi_archdetect.sh b/init/eessi_archdetect.sh index ddfed1bfae..ad6dce6f9a 100755 --- a/init/eessi_archdetect.sh +++ b/init/eessi_archdetect.sh @@ -1,4 +1,22 @@ #!/usr/bin/env bash + +# Confirm the current shell is Bash >= 4 +# (works for sh, bash, dash, zsh, ksh, but not fish, tcsh, elvish) +if [ -n "$BASH_VERSION" ]; then + # Extract the major version numbers + bash_version=$(echo "$BASH_VERSION" | grep -oP '^\d+\.\d+') + major_version=$(echo "$bash_version" | cut -d. -f1) + + # Check if the major version is 4 or higher + if [ "$major_version" -lt 4 ]; then + echo "Error: This script must be run with Bash >= 4, you have $BASH_VERSION." >&2 + exit 1 + fi +else + echo "Error: This script must be run with Bash." >&2 + exit 1 +fi + VERSION="1.1.0" # default log level: only emit warnings or errors