completion/system: accomodate multiple versions
For Homebrew, switch between v1 and v2 of bash-completion based on whether the running Bash shell is new enough to use v2.pull/1915/head
parent
5782325dea
commit
ecfcaba32e
|
|
@ -5,14 +5,16 @@
|
||||||
|
|
||||||
if shopt -qo nounset
|
if shopt -qo nounset
|
||||||
then # Bash-completion is too large and complex to expect to handle unbound variables throughout the whole codebase.
|
then # Bash-completion is too large and complex to expect to handle unbound variables throughout the whole codebase.
|
||||||
BASH_IT_RESTORE_NOUNSET=true
|
__bash_it_restore_nounset=true
|
||||||
shopt -uo nounset
|
shopt -uo nounset
|
||||||
else
|
else
|
||||||
BASH_IT_RESTORE_NOUNSET=false
|
__bash_it_restore_nounset=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -r "${BASH_COMPLETION:-}" ]] ; then
|
if [[ -r "${BASH_COMPLETION:-}" ]] ; then
|
||||||
|
# shellcheck disable=SC1091
|
||||||
source "${BASH_COMPLETION}"
|
source "${BASH_COMPLETION}"
|
||||||
|
|
||||||
elif [[ -r /etc/bash_completion ]] ; then
|
elif [[ -r /etc/bash_completion ]] ; then
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
source /etc/bash_completion
|
source /etc/bash_completion
|
||||||
|
|
@ -24,15 +26,34 @@ elif [[ -r /etc/profile.d/bash_completion.sh ]] ; then
|
||||||
|
|
||||||
elif _bash_it_homebrew_check
|
elif _bash_it_homebrew_check
|
||||||
then
|
then
|
||||||
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path
|
: ${BASH_COMPLETION_COMPAT_DIR:=$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d}
|
||||||
if [[ -r "$BASH_IT_HOMEBREW_PREFIX"/etc/profile.d/bash_completion.sh ]] ; then
|
|
||||||
# shellcheck disable=SC1090
|
case "${BASH_VERSION}" in
|
||||||
source "$BASH_IT_HOMEBREW_PREFIX"/etc/profile.d/bash_completion.sh
|
1*|2*|3.0*|3.1*)
|
||||||
fi
|
_log_warning "Cannot load completion due to version of shell."
|
||||||
|
;;
|
||||||
|
3.2*|4.0*|4.1*)
|
||||||
|
# Import version 1.x of bash-completion, if installed.
|
||||||
|
BASH_COMPLETION="$BASH_IT_HOMEBREW_PREFIX/opt/bash-completion@1/etc/bash_completion"
|
||||||
|
if [[ -r "$BASH_COMPLETION" ]] ; then
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
source "$BASH_COMPLETION"
|
||||||
|
else
|
||||||
|
unset BASH_COMPLETION
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
4.2*|5*|*)
|
||||||
|
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path
|
||||||
|
if [[ -r "$BASH_IT_HOMEBREW_PREFIX"/etc/profile.d/bash_completion.sh ]] ; then
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
source "$BASH_IT_HOMEBREW_PREFIX"/etc/profile.d/bash_completion.sh
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $BASH_IT_RESTORE_NOUNSET
|
if $__bash_it_restore_nounset
|
||||||
then
|
then
|
||||||
shopt -so nounset
|
shopt -so nounset
|
||||||
fi
|
fi
|
||||||
unset BASH_IT_RESTORE_NOUNSET
|
unset __bash_it_restore_nounset
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue