oh-my-bash: Check Bash version on startup

This commit is contained in:
Koichi Murase
2022-01-15 14:39:30 +09:00
parent 5eaf1a25a4
commit 59a0beee7c
2 changed files with 12 additions and 2 deletions

View File

@ -73,7 +73,6 @@
################################################################################ ################################################################################
_omb_version=10000 _omb_version=10000
_omb_bash_version=$((BASH_VERSINFO[0] * 10000 + BASH_VERSINFO[1] * 100 + BASH_VERSINFO[2]))
function _omb_util_setexit { function _omb_util_setexit {
return "$1" return "$1"
@ -93,7 +92,7 @@ function __omb_util_defun_deprecate__message {
function _omb_util_defun_deprecate { function _omb_util_defun_deprecate {
local warning= local warning=
((_omb_version>=$1)) && ((_omb_version >= $1)) &&
warning='__omb_util_defun_deprecate__message "$2" "$3"; ' warning='__omb_util_defun_deprecate__message "$2" "$3"; '
builtin eval -- "function $2 { $warning$3 \"\$@\"; }" builtin eval -- "function $2 { $warning$3 \"\$@\"; }"
} }

View File

@ -10,6 +10,17 @@ case $- in
*) return;; *) return;;
esac esac
if [ ! -n "${BASH_VERSION-}" ]; then
printf '%s\n' 'oh-my-bash: This is not a Bash. Use OMB with Bash 3.2 or higher.' >&2
return 1
fi
_omb_bash_version=$((BASH_VERSINFO[0] * 10000 + BASH_VERSINFO[1] * 100 + BASH_VERSINFO[2]))
if ((_omb_bash_version < 30200)); then
printf '%s\n' "oh-my-bash: OMB does not support this version of Bash ($BASH_VERSION)" >&2
printf '%s\n' "oh-my-bash: Use OMB with Bash 3.2 or higher" >&2
return 1
fi
# Check for updates on initial load... # Check for updates on initial load...
if [[ $DISABLE_AUTO_UPDATE != true ]]; then if [[ $DISABLE_AUTO_UPDATE != true ]]; then
source "$OSH"/tools/check_for_upgrade.sh source "$OSH"/tools/check_for_upgrade.sh