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/pipx.completion.bash
completion/available/rustup.completion.bash completion/available/rustup.completion.bash
completion/available/sdkman.completion.bash completion/available/sdkman.completion.bash
completion/available/system.completion.bash
completion/available/vault.completion.bash completion/available/vault.completion.bash
completion/available/vuejs.completion.bash completion/available/vuejs.completion.bash
completion/available/wpscan.completion.bash completion/available/wpscan.completion.bash

View File

@ -1,59 +1,60 @@
#!/usr/bin/env bash # shellcheck shell=bash
# #
# Loads the system's Bash completion modules. # Loads the system's Bash completion modules.
# If Homebrew is installed (OS X), it's Bash completion modules are loaded. # If Homebrew is installed (OS X), it's Bash completion modules are loaded.
if shopt -qo nounset # Load before other completions
then # Bash-completion is too large and complex to expect to handle unbound variables throughout the whole codebase. # 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 __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 # shellcheck disable=SC1090
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
# Some distribution makes use of a profile.d script to import completion. # Some distribution makes use of a profile.d script to import completion.
elif [[ -r /etc/profile.d/bash_completion.sh ]] ; then elif [[ -r /etc/profile.d/bash_completion.sh ]]; then
# shellcheck disable=SC1091 # shellcheck disable=SC1091
source /etc/profile.d/bash_completion.sh source /etc/profile.d/bash_completion.sh
elif _bash_it_homebrew_check elif _bash_it_homebrew_check; then
then : "${BASH_COMPLETION_COMPAT_DIR:=$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d}"
: ${BASH_COMPLETION_COMPAT_DIR:=$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d}
case "${BASH_VERSION}" in case "${BASH_VERSION}" in
1*|2*|3.0*|3.1*) 1* | 2* | 3.0* | 3.1*)
_log_warning "Cannot load completion due to version of shell. Are you using Bash 3.2+?" _log_warning "Cannot load completion due to version of shell. Are you using Bash 3.2+?"
;; ;;
3.2*|4.0*|4.1*) 3.2* | 4.0* | 4.1*)
# Import version 1.x of bash-completion, if installed. # Import version 1.x of bash-completion, if installed.
BASH_COMPLETION="$BASH_IT_HOMEBREW_PREFIX/opt/bash-completion@1/etc/bash_completion" BASH_COMPLETION="$BASH_IT_HOMEBREW_PREFIX/opt/bash-completion@1/etc/bash_completion"
if [[ -r "$BASH_COMPLETION" ]] ; then if [[ -r "$BASH_COMPLETION" ]]; then
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "$BASH_COMPLETION" source "$BASH_COMPLETION"
else else
unset BASH_COMPLETION unset BASH_COMPLETION
fi fi
;; ;;
4.2*|5*|*) 4.2* | 5* | *)
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path # 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 if [[ -r "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh" ]]; then
# shellcheck disable=SC1090 # shellcheck disable=SC1091
source "$BASH_IT_HOMEBREW_PREFIX"/etc/profile.d/bash_completion.sh source "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh"
fi fi
;; ;;
esac esac
fi fi
if $__bash_it_restore_nounset if [[ ${__bash_it_restore_nounset:-false} == "true" ]]; then
then
shopt -so nounset shopt -so nounset
fi fi
unset __bash_it_restore_nounset 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/250---base.plugin.bash"
assert_link_exist "$BASH_IT/enabled/365---alias-completion.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---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" { @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/250---base.plugin.bash"
assert_link_exist "$BASH_IT/enabled/365---alias-completion.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---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" { @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/250---base.plugin.bash"
assert_link_not_exist "$BASH_IT/enabled/365---alias-completion.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---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" { @test "helper: profile save and load" {