Merge pull request #2013 from gaelicWizard/completion/system

completion/system: load earlier than others
pull/1958/head
Noah Gorny 2022-01-09 01:13:23 +02:00 committed by GitHub
commit f2bff34493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 41 deletions

View File

@ -72,6 +72,7 @@ completion/available/pipenv.completion.bash
completion/available/pipx.completion.bash
completion/available/rustup.completion.bash
completion/available/sdkman.completion.bash
completion/available/system.completion.bash
completion/available/vault.completion.bash
completion/available/vuejs.completion.bash
completion/available/wpscan.completion.bash

View File

@ -1,10 +1,13 @@
#!/usr/bin/env bash
# shellcheck shell=bash
#
# Loads the system's Bash completion modules.
# If Homebrew is installed (OS X), it's Bash completion modules are loaded.
if shopt -qo nounset
then # Bash-completion is too large and complex to expect to handle unbound variables throughout the whole codebase.
# Load before other completions
# BASH_IT_LOAD_PRIORITY: 325
# Bash-completion is too large and complex to expect to handle unbound variables throughout the whole codebase.
if shopt -qo nounset; then
__bash_it_restore_nounset=true
shopt -uo nounset
else
@ -12,7 +15,7 @@ else
fi
if [[ -r "${BASH_COMPLETION:-}" ]]; then
# shellcheck disable=SC1091
# shellcheck disable=SC1090
source "${BASH_COMPLETION}"
elif [[ -r /etc/bash_completion ]]; then
@ -24,9 +27,8 @@ elif [[ -r /etc/profile.d/bash_completion.sh ]] ; then
# shellcheck disable=SC1091
source /etc/profile.d/bash_completion.sh
elif _bash_it_homebrew_check
then
: ${BASH_COMPLETION_COMPAT_DIR:=$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d}
elif _bash_it_homebrew_check; then
: "${BASH_COMPLETION_COMPAT_DIR:=$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d}"
case "${BASH_VERSION}" in
1* | 2* | 3.0* | 3.1*)
@ -44,16 +46,15 @@ then
;;
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
if [[ -r "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh" ]]; then
# shellcheck disable=SC1091
source "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh"
fi
;;
esac
fi
if $__bash_it_restore_nounset
then
if [[ ${__bash_it_restore_nounset:-false} == "true" ]]; then
shopt -so nounset
fi
unset __bash_it_restore_nounset

View File

@ -31,7 +31,7 @@ function local_setup {
assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash"
assert_link_exist "$BASH_IT/enabled/365---alias-completion.plugin.bash"
assert_link_exist "$BASH_IT/enabled/350---bash-it.completion.bash"
assert_link_exist "$BASH_IT/enabled/350---system.completion.bash"
assert_link_exist "$BASH_IT/enabled/325---system.completion.bash"
}
@test "install: verify that a backup file is created" {

View File

@ -296,7 +296,7 @@ function local_setup {
assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash"
assert_link_exist "$BASH_IT/enabled/365---alias-completion.plugin.bash"
assert_link_exist "$BASH_IT/enabled/350---bash-it.completion.bash"
assert_link_exist "$BASH_IT/enabled/350---system.completion.bash"
assert_link_exist "$BASH_IT/enabled/325---system.completion.bash"
}
@test "helper: profile save command sanity" {
@ -356,7 +356,7 @@ function local_setup {
assert_link_not_exist "$BASH_IT/enabled/250---base.plugin.bash"
assert_link_not_exist "$BASH_IT/enabled/365---alias-completion.plugin.bash"
assert_link_not_exist "$BASH_IT/enabled/350---bash-it.completion.bash"
assert_link_not_exist "$BASH_IT/enabled/350---system.completion.bash"
assert_link_not_exist "$BASH_IT/enabled/325---system.completion.bash"
}
@test "helper: profile save and load" {