From 855c10180af31f5c2a8fb54424f8227eca768107 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Wed, 17 Jul 2024 13:27:59 +0900 Subject: [PATCH] Check Bash version --- mcfly.bash | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mcfly.bash b/mcfly.bash index 87d26c2..8e20a96 100644 --- a/mcfly.bash +++ b/mcfly.bash @@ -1,6 +1,13 @@ #!/bin/bash function mcfly_initialize { + # Note: We avoid using [[ ... ]] to check the Bash version because we are + # even unsure whether it is available before confirming the Bash version. + if [ -z "${BASH_VERSINFO-}" ] || [ "${BASH_VERSINFO-}" -lt 3 ]; then + printf 'mcfly.bash: This setup requires Bash >= 3.0.' >&2 + return 1 + fi + unset -f "${FUNCNAME[0]}" # Ensure stdin is a tty