Skip to content

Commit

Permalink
oh-my-bash: Check Bash version on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 19, 2022
1 parent 5eaf1a2 commit 59a0bee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
################################################################################

_omb_version=10000
_omb_bash_version=$((BASH_VERSINFO[0] * 10000 + BASH_VERSINFO[1] * 100 + BASH_VERSINFO[2]))

function _omb_util_setexit {
return "$1"
Expand All @@ -93,7 +92,7 @@ function __omb_util_defun_deprecate__message {

function _omb_util_defun_deprecate {
local warning=
((_omb_version>=$1)) &&
((_omb_version >= $1)) &&
warning='__omb_util_defun_deprecate__message "$2" "$3"; '
builtin eval -- "function $2 { $warning$3 \"\$@\"; }"
}
Expand Down
11 changes: 11 additions & 0 deletions oh-my-bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ case $- in
*) return;;
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...
if [[ $DISABLE_AUTO_UPDATE != true ]]; then
source "$OSH"/tools/check_for_upgrade.sh
Expand Down

0 comments on commit 59a0bee

Please sign in to comment.