From d8fa62a5f951a82b78958b936be31913f1c56430 Mon Sep 17 00:00:00 2001 From: Einhard Leichtfuß Date: Mon, 23 Dec 2024 12:38:10 +0100 Subject: Check for minimum Bash version (5.2) We need 5.2 for the `globskipdots` shell option. 5.2 happens to be the current version in Debian 12 (bookworm). --- src/basic.bash | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/basic.bash b/src/basic.bash index a9d0a10..5af4cd6 100644 --- a/src/basic.bash +++ b/src/basic.bash @@ -3,6 +3,24 @@ # Copyright 2020-2024 Einhard Leichtfuß +######################### +## Minimum Bash version + +if [ -z "$BASH_VERSINFO" ] +then + printf 'Failed: $BASH_VERSINFO undefined or null.\n' >&2 + exit 1 +fi +if [[ ${BASH_VERSINFO[0]:-0} -lt 5 + || ( ${BASH_VERSINFO[0]:-0} -eq 5 && ${BASH_VERSINFO[1]:-0} -lt 2 ) + ]] +then + printf 'Failed: Bash version < 5.2.\n' >&2 + exit 1 +fi + + + ################################### ## Error and termination handling -- cgit v1.2.3