Check Bash version and fail gracefully if it's too old

This closes #55.
pull/56/head
Hugo Locurcio 2020-04-28 09:27:56 +02:00
parent 30aeef8f65
commit fe6a028641
1 changed files with 15 additions and 0 deletions

15
bashtop
View File

@ -32,6 +32,21 @@ declare -x LC_MESSAGES="C" LC_NUMERIC="C" LC_ALL=""
shopt -qu failglob nullglob
shopt -qs extglob globasciiranges globstar
#* Fail if Bash version is below 4.4
bash_version_major="$(echo $BASH_VERSION | cut -d "." -f 1)"
bash_version_minor="$(echo $BASH_VERSION | cut -d "." -f 2)"
if [[ "$bash_version_major" -lt 4 ]]; then
echo "ERROR: Bash 4.4 or later is required (you are using Bash $bash_version_major.$bash_version_minor)."
echo " Consider upgrading your distribution to get a more recent Bash version."
exit 1
else
if [[ "$bash_version_major" == 4 && "$bash_version_minor" -lt 4 ]]; then
echo "ERROR: Bash 4.4 or later is required (you are using Bash $bash_version_major.$bash_version_minor)."
echo " Consider upgrading your distribution to get a more recent Bash version."
exit 1
fi
fi
declare -a banner banner_colors
banner=(