diff --git a/completion/available/apm.completion.bash b/completion/available/apm.completion.bash index c3dcfe45f8..9737938f24 100644 --- a/completion/available/apm.completion.bash +++ b/completion/available/apm.completion.bash @@ -1,4 +1,4 @@ # shellcheck shell=bash about-completion "apm completion" -# shellcheck disable=SC1090 -source "${BASH_IT}"/vendor/github.com/vigo/apm-bash-completion/apm +# shellcheck source-path=SCRIPTDIR/../../vendor/github.com/vigo/apm-bash-completion +source "${BASH_IT?}/vendor/github.com/vigo/apm-bash-completion/apm" diff --git a/completion/available/awless.completion.bash b/completion/available/awless.completion.bash index 98a5d38881..ba7e422684 100644 --- a/completion/available/awless.completion.bash +++ b/completion/available/awless.completion.bash @@ -1,5 +1,16 @@ # shellcheck shell=bash -if _command_exists awless; then - # shellcheck disable=SC1090 - source <(awless completion bash) + +# Make sure awless is installed +if ! _binary_exists awless; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists awless; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +# shellcheck disable=SC1090 +source <(awless completion bash) diff --git a/completion/available/awscli.completion.bash b/completion/available/awscli.completion.bash index a30418373a..4e46f40c2c 100644 --- a/completion/available/awscli.completion.bash +++ b/completion/available/awscli.completion.bash @@ -1,6 +1,14 @@ # shellcheck shell=bash -if _command_exists aws_completer -then - complete -C "$(command -v aws_completer)" aws +# Make sure aws is installed +if ! _binary_exists aws_completer || ! _binary_exists aws; then + _log_warning "Without '$_' installed, this completion won't be too useful." fi + +# Don't handle completion if it's already managed +if _completion_exists aws; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +complete -C aws_completer aws diff --git a/completion/available/cargo.completion.bash b/completion/available/cargo.completion.bash index d276ee7298..7a3d252008 100644 --- a/completion/available/cargo.completion.bash +++ b/completion/available/cargo.completion.bash @@ -1,6 +1,16 @@ # shellcheck shell=bash -# cargo (Rust package manager) completion +about-completion "cargo (Rust package manager) completion" -if _binary_exists rustup && _binary_exists cargo; then - eval "$(rustup completions bash cargo)" +# Make sure cargo is installed +if ! _binary_exists rustup || ! _binary_exists cargo; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists cargo; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +eval "$(rustup completions bash cargo)" diff --git a/completion/available/conda.completion.bash b/completion/available/conda.completion.bash index f5a61e5907..84399caec3 100644 --- a/completion/available/conda.completion.bash +++ b/completion/available/conda.completion.bash @@ -1,5 +1,4 @@ # shellcheck shell=bash -cite "about-completion" about-completion "conda completion" if _command_exists conda; then diff --git a/completion/available/consul.completion.bash b/completion/available/consul.completion.bash index 511cf37209..84f46f4365 100644 --- a/completion/available/consul.completion.bash +++ b/completion/available/consul.completion.bash @@ -1,7 +1,16 @@ # shellcheck shell=bash -cite "about-completion" about-completion "Hashicorp consul completion" -if _command_exists consul; then - complete -C "$(command -v consul)" consul +# Make sure consul is installed +if ! _binary_exists consul; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists consul; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +complete -C consul consul diff --git a/completion/available/crystal.completion.bash b/completion/available/crystal.completion.bash index 7644ffd4d4..950459aa71 100644 --- a/completion/available/crystal.completion.bash +++ b/completion/available/crystal.completion.bash @@ -1 +1,4 @@ -_log_warning 'Bash completion for "crystal" is now covered by "system". This completion can be disabled.' +# shellcheck shell=bash + +_log_warning 'Bash completion for "crystal" is now covered by "system".' +_disable-completion "crystal" diff --git a/completion/available/defaults.completion.bash b/completion/available/defaults.completion.bash index 39d7ea95b0..9fb00da619 100644 --- a/completion/available/defaults.completion.bash +++ b/completion/available/defaults.completion.bash @@ -1,5 +1,6 @@ # shellcheck shell=bash -if test -s "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash"; then - source "$_" +if [[ -s "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash" ]]; then + # shellcheck source-path=SCRIPTDIR/../../vendor/github.com/gaelicWizard/bash-progcomp + source "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash" fi diff --git a/completion/available/docker.completion.bash b/completion/available/docker.completion.bash index 3f83a87461..ecbf29cf22 100644 --- a/completion/available/docker.completion.bash +++ b/completion/available/docker.completion.bash @@ -1,24 +1,37 @@ # shellcheck shell=bash -cite "about-completion" about-completion "docker completion" # Make sure docker is installed -_command_exists docker || return +if ! _binary_exists docker; then + _log_warning "Without '$_' installed, this completion won't be too useful." +fi # Don't handle completion if it's already managed -_completion_exists docker && return +if _completion_exists docker; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi _docker_bash_completion_paths=( - # MacOS + # MacOS App '/Applications/Docker.app/Contents/Resources/etc/docker.bash-completion' - # Linux + # Command Line '/usr/share/bash-completion/completions/docker' ) -for fn in "${_docker_bash_completion_paths[@]}"; do - if [ -r "$fn" ]; then +# Load the first completion file found +_docker_bash_completion_found=false +for _comp_path in "${_docker_bash_completion_paths[@]}"; do + if [[ -r "$_comp_path" ]]; then + _docker_bash_completion_found=true # shellcheck disable=SC1090 - source "$fn" + source "$_comp_path" break fi done + +# Cleanup +if [[ "${_docker_bash_completion_found}" == false ]]; then + _log_warning "no completion files found - please try enabling the 'system' completion instead." +fi +unset "${!_docker_bash_completion@}" diff --git a/completion/available/drush.completion.bash b/completion/available/drush.completion.bash index 6628c65513..ccee2c3edf 100644 --- a/completion/available/drush.completion.bash +++ b/completion/available/drush.completion.bash @@ -1,2 +1,3 @@ +# shellcheck shell=bash _log_warning 'Bash completion for "drush" is now deprecated, as it used code with incompatible license. Please disable this completion and use the instructions from "drush" developers instead.' diff --git a/completion/available/flutter.completion.bash b/completion/available/flutter.completion.bash index 62befc824d..6627287611 100644 --- a/completion/available/flutter.completion.bash +++ b/completion/available/flutter.completion.bash @@ -1,5 +1,15 @@ -#!/usr/bin/bash +# shellcheck shell=bash -if _command_exists flutter; then - eval "$(flutter bash-completion)" +# Make sure flutter is installed +if ! _binary_exists flutter; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists flutter; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +eval "$(flutter bash-completion)" diff --git a/completion/available/gcloud.completion.bash b/completion/available/gcloud.completion.bash index 63073e8ed3..514d8b4c3d 100644 --- a/completion/available/gcloud.completion.bash +++ b/completion/available/gcloud.completion.bash @@ -1,5 +1,4 @@ # shellcheck shell=bash -cite "about-completion" about-completion "Google Cloud SDK completion" if _command_exists gcloud; then diff --git a/completion/available/github-cli.completion.bash b/completion/available/github-cli.completion.bash index 4a6113945c..d10ba34e7d 100644 --- a/completion/available/github-cli.completion.bash +++ b/completion/available/github-cli.completion.bash @@ -1,9 +1,15 @@ # shellcheck shell=bash -cite "about-completion" about-completion "GitHub CLI completion" -if _binary_exists gh; then - # If gh already completed, stop - _completion_exists gh && return - eval "$(gh completion --shell=bash)" +if ! _binary_exists gh; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists gh; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +eval "$(gh completion --shell=bash)" diff --git a/completion/available/helm.completion.bash b/completion/available/helm.completion.bash index 0dae7af46b..9809cfb7ff 100644 --- a/completion/available/helm.completion.bash +++ b/completion/available/helm.completion.bash @@ -1,7 +1,16 @@ # shellcheck shell=bash -cite "about-completion" about-completion "helm (Kubernetes Package Manager) completion" -if _command_exists helm; then - eval "$(helm completion bash)" +# Make sure helm is installed +if ! _binary_exists helm; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists helm; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +eval "$(helm completion bash)" diff --git a/completion/available/homesick.completion.bash b/completion/available/homesick.completion.bash index ed6f6e79ed..41ab67f146 100644 --- a/completion/available/homesick.completion.bash +++ b/completion/available/homesick.completion.bash @@ -1,2 +1,3 @@ +# shellcheck shell=bash _log_warning 'Bash completion for "homesick" is now deprecated, as it used unlicensed code. Please disable this completion and use the instructions from "homesick" bash completion developers instead.' diff --git a/completion/available/jungle.completion.bash b/completion/available/jungle.completion.bash index e190d1438a..7ea8443b86 100644 --- a/completion/available/jungle.completion.bash +++ b/completion/available/jungle.completion.bash @@ -1,7 +1,16 @@ # shellcheck shell=bash -cite "about-completion" about-completion "jungle(AWS cli tool) completion" -if _command_exists jungle; then - eval "$(_JUNGLE_COMPLETE=source jungle)" +# Make sure jungle is installed +if ! _binary_exists jungle; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists jungle; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +eval "$(_JUNGLE_COMPLETE=source jungle)" diff --git a/completion/available/kind.completion.bash b/completion/available/kind.completion.bash index be12a2d29c..abe8f0a4b8 100644 --- a/completion/available/kind.completion.bash +++ b/completion/available/kind.completion.bash @@ -1,5 +1,15 @@ -#!/usr/bin/env bash +# shellcheck shell=bash -if _command_exists kind; then - eval "$(kind completion bash)" +# Make sure kind is installed +if ! _binary_exists kind; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists kind; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +eval "$(kind completion bash)" diff --git a/completion/available/kontena.completion.bash b/completion/available/kontena.completion.bash index 916ee15f92..869bea9f58 100644 --- a/completion/available/kontena.completion.bash +++ b/completion/available/kontena.completion.bash @@ -1,5 +1,16 @@ # shellcheck shell=bash -if _command_exists kontena; then - # shellcheck disable=SC1090 - source "$(kontena whoami --bash-completion-path)" + +# Make sure kontena is installed +if ! _binary_exists kontena; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists kontena; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +# shellcheck disable=SC1090 +source "$(kontena whoami --bash-completion-path)" diff --git a/completion/available/kubectl.completion.bash b/completion/available/kubectl.completion.bash index a9c498b601..1e09b10bc0 100644 --- a/completion/available/kubectl.completion.bash +++ b/completion/available/kubectl.completion.bash @@ -1,7 +1,16 @@ # shellcheck shell=bash -cite "about-completion" about-completion "kubectl (Kubernetes CLI) completion" -if _binary_exists kubectl; then - eval "$(kubectl completion bash)" +# Make sure kubectl is installed +if ! _binary_exists kubectl; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists kubectl; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +eval "$(kubectl completion bash)" diff --git a/completion/available/laravel.completion.bash b/completion/available/laravel.completion.bash index 8f03256896..74ed8d620e 100644 --- a/completion/available/laravel.completion.bash +++ b/completion/available/laravel.completion.bash @@ -1,6 +1,15 @@ # shellcheck shell=bash -_command_exists laravel || return +# Make sure laravel is installed +if ! _binary_exists laravel; then + _log_warning "Without '$_' installed, this completion won't be too useful." +fi + +# Don't handle completion if it's already managed +if _completion_exists laravel; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi function __laravel_completion() { local OPTS=('-h' '--help' '-q' '--quiet' '--ansi' '--no-ansi' '-n' '--no-interaction' '-v' '-vv' '-vvv' '--verbose' 'help' 'list' 'new') diff --git a/completion/available/makefile.completion.bash b/completion/available/makefile.completion.bash index e72ba6fd3b..b518bb5793 100644 --- a/completion/available/makefile.completion.bash +++ b/completion/available/makefile.completion.bash @@ -1,33 +1,35 @@ +# shellcheck shell=bash + # Bash completion for Makefile # Loosely adapted from http://stackoverflow.com/a/38415982/1472048 -_makecomplete() { - COMPREPLY=() +function _makecomplete() { + local cur="${COMP_WORDS[COMP_CWORD]}" + local files=() targets=() line f + COMPREPLY=() - # https://www.gnu.org/software/make/manual/html_node/Makefile-Names.html - local files=() - for f in 'GNUmakefile' 'makefile' 'Makefile' ; do - [ -f "$f" ] && files+=("$f") - done + # https://www.gnu.org/software/make/manual/html_node/Makefile-Names.html + for f in 'GNUmakefile' 'makefile' 'Makefile'; do + [[ -f "$f" ]] && files+=("$f") + done - [ "${#files[@]}" -eq 0 ] && return 0 + [[ "${#files[@]}" -eq 0 ]] && return 0 - # collect all targets - local targets=() - for f in "${files[@]}" ; do - while IFS='' read -r line ; do - targets+=("$line") - done < <(grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' "$f" | cut -d':' -f1) - done + # collect all targets + for f in "${files[@]}"; do + while IFS='' read -r line; do + targets+=("$line") + done < <(grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' "$f" | cut -d':' -f1) + done - [ "${#targets[@]}" -eq 0 ] && return 0 + [[ "${#targets[@]}" -eq 0 ]] && return 0 - # use the targets for completion - while IFS='' read -r line ; do - COMPREPLY+=("$line") - done < <(compgen -W "$(tr ' ' '\n' <<<"${targets[@]}" | sort -u)" -- "${COMP_WORDS[COMP_CWORD]}") + # use the targets for completion + while IFS='' read -r line; do + COMPREPLY+=("$line") + done < <(compgen -W "$(tr ' ' '\n' <<< "${targets[@]}" | sort -u)" -- "${cur}") - return 0 + return 0 } complete -o nospace -F _makecomplete make diff --git a/completion/available/minikube.completion.bash b/completion/available/minikube.completion.bash index 44076362ce..a90ef905a6 100644 --- a/completion/available/minikube.completion.bash +++ b/completion/available/minikube.completion.bash @@ -1,6 +1,16 @@ # shellcheck shell=bash -# minikube (Local Kubernetes) completion +about-completion "minikube (Local Kubernetes) completion" -if _command_exists minikube; then - eval "$(minikube completion bash)" +# Make sure minikube is installed +if ! _binary_exists minikube; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists minikube; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +eval "$(minikube completion bash)" diff --git a/completion/available/minishift.completion.bash b/completion/available/minishift.completion.bash index 5679eae80f..f8525b331d 100644 --- a/completion/available/minishift.completion.bash +++ b/completion/available/minishift.completion.bash @@ -1 +1,16 @@ -_command_exists minishift && source <(minishift completion bash) +# shellcheck shell=bash + +# Make sure minishift is installed +if ! _binary_exists minishift; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 +fi + +# Don't handle completion if it's already managed +if _completion_exists minishift; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +# shellcheck disable=SC1090 +source <(minishift completion bash) diff --git a/completion/available/ng.completion.bash b/completion/available/ng.completion.bash index f219b30396..bc1ae8d140 100644 --- a/completion/available/ng.completion.bash +++ b/completion/available/ng.completion.bash @@ -1,8 +1,20 @@ -if _command_exists ng; then - # No longer supported, please see https://github.com/angular/angular-cli/issues/11043 - # Fix courtesy of https://stackoverflow.com/questions/50194674/ng-completion-no-longer-exists - # . <(ng completion --bash) +# shellcheck shell=bash - NG_COMMANDS="add build config doc e2e generate help lint new run serve test update version xi18n" - complete -W "$NG_COMMANDS" ng +# Make sure ng is installed +if ! _binary_exists ng; then + _log_warning "Without '$_' installed, this completion won't be too useful." fi + +# Don't handle completion if it's already managed +if _completion_exists ng; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +# No longer supported, please see https://github.com/angular/angular-cli/issues/11043 +# Fix courtesy of https://stackoverflow.com/questions/50194674/ng-completion-no-longer-exists +# source <(ng completion --bash) + +_ng_bash_completion_candidates=("add" "build" "config" "doc" "e2e" "generate" "help" "lint" "new" "run" "serve" "test" "update" "version" "xi18n") +complete -W "${_ng_bash_completion_candidates[*]}" ng +unset "${!_ng_bash_completion@}" diff --git a/completion/available/npm.completion.bash b/completion/available/npm.completion.bash index cf24585ef7..7312ac54a5 100644 --- a/completion/available/npm.completion.bash +++ b/completion/available/npm.completion.bash @@ -1,7 +1,16 @@ # shellcheck shell=bash -cite "about-completion" about-completion "npm (Node Package Manager) completion" -if _command_exists npm; then - eval "$(npm completion)" +# Make sure npm is installed +if ! _binary_exists npm; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists npm; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +eval "$(npm completion)" diff --git a/completion/available/nvm.completion.bash b/completion/available/nvm.completion.bash index a82b82b61a..9126f4d68b 100644 --- a/completion/available/nvm.completion.bash +++ b/completion/available/nvm.completion.bash @@ -1,8 +1,7 @@ -#!/usr/bin/env bash +# shellcheck shell=bash +about-completion "nvm (Node Version Manager) completion" -# nvm (Node Version Manager) completion - -if [ "$NVM_DIR" ] && [ -r "$NVM_DIR"/bash_completion ]; -then - . "$NVM_DIR"/bash_completion +if [[ -n "${NVM_DIR:-}" && -s "${NVM_DIR}/bash_completion" ]]; then + # shellcheck disable=SC1091 + source "${NVM_DIR}/bash_completion" fi diff --git a/completion/available/openshift.completion.bash b/completion/available/openshift.completion.bash index 1e7b681506..05b505119c 100644 --- a/completion/available/openshift.completion.bash +++ b/completion/available/openshift.completion.bash @@ -1 +1,16 @@ -_command_exists oc && source <(oc completion bash) +# shellcheck shell=bash + +# Make sure oc is installed +if ! _binary_exists oc; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 +fi + +# Don't handle completion if it's already managed +if _completion_exists oc; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +# shellcheck disable=SC1090 +source <(oc completion bash) diff --git a/completion/available/packer.completion.bash b/completion/available/packer.completion.bash index 2301f0f226..cfae87006f 100644 --- a/completion/available/packer.completion.bash +++ b/completion/available/packer.completion.bash @@ -1,7 +1,16 @@ # shellcheck shell=bash -cite "about-completion" about-completion "packer completion" -if _binary_exists packer; then - complete -C packer packer +# Make sure packer is installed +if ! _binary_exists packer; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists packer; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +complete -C packer packer diff --git a/completion/available/pew.completion.bash b/completion/available/pew.completion.bash index 04e67ecbf5..aa980fd47f 100644 --- a/completion/available/pew.completion.bash +++ b/completion/available/pew.completion.bash @@ -1,6 +1,16 @@ # shellcheck shell=bash -if _command_exists pew -then - source "$(pew shell_config)" +# Make sure docker is installed +if ! _binary_exists docker; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists docker; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +# shellcheck disable=SC1090 +source "$(pew shell_config)" diff --git a/completion/available/pipenv.completion.bash b/completion/available/pipenv.completion.bash index 4adfab9595..1f3e082e4d 100644 --- a/completion/available/pipenv.completion.bash +++ b/completion/available/pipenv.completion.bash @@ -1,4 +1,15 @@ # shellcheck shell=bash -if _command_exists pipenv; then - eval "$(_PIPENV_COMPLETE=bash_source pipenv)" + +# Make sure pipenv is installed +if ! _binary_exists pipenv; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists pipenv; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +eval "$(_PIPENV_COMPLETE=bash_source pipenv)" diff --git a/completion/available/rustup.completion.bash b/completion/available/rustup.completion.bash index 1cf8bc95b4..751cd96bb1 100644 --- a/completion/available/rustup.completion.bash +++ b/completion/available/rustup.completion.bash @@ -1,7 +1,16 @@ # shellcheck shell=bash +about-completion "rustup (Rust toolchain installer) completion" -# rustup (Rust toolchain installer) completion +# Make sure rustup is installed +if ! _binary_exists rustup; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 +fi -if _binary_exists rustup; then - eval "$(rustup completions bash)" +# Don't handle completion if it's already managed +if _completion_exists rustup; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 fi + +eval "$(rustup completions bash)" diff --git a/completion/available/rvm.completion.bash b/completion/available/rvm.completion.bash index cd8ded0468..b00f0b6e1d 100644 --- a/completion/available/rvm.completion.bash +++ b/completion/available/rvm.completion.bash @@ -1,5 +1,8 @@ -#!/usr/bin/env bash +# shellcheck shell=bash # Bash completion support for RVM. # Source: https://rvm.io/workflow/completion -[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion +if [[ -n "${rvm_path:-}" && -s "${rvm_path}/scripts/completion" ]]; then + # shellcheck disable=SC1091 + source "${rvm_path}/scripts/completion" +fi diff --git a/completion/available/svn.completion.bash b/completion/available/svn.completion.bash index 2f0a23fe97..df8cf7e8a3 100644 --- a/completion/available/svn.completion.bash +++ b/completion/available/svn.completion.bash @@ -3,7 +3,9 @@ # Locate and load completions for `svn`. # Make sure svn is installed -_command_exists svn || return +if ! _binary_exists svn; then + _log_warning "Without '$_' installed, this completion won't be too useful." +fi # Don't handle completion if it's already managed if _completion_exists svn; then diff --git a/completion/available/terraform.completion.bash b/completion/available/terraform.completion.bash index 1452fca8b2..5c2a29767c 100644 --- a/completion/available/terraform.completion.bash +++ b/completion/available/terraform.completion.bash @@ -1,10 +1,16 @@ -#!/usr/bin/env bash +# shellcheck shell=bash # Make sure terraform is installed -_command_exists terraform || return +if ! _binary_exists terraform; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 +fi # Don't handle completion if it's already managed -complete -p terraform &>/dev/null && return +if _completion_exists terraform; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi # Terraform completes itself complete -C terraform terraform diff --git a/completion/available/todo.completion.bash b/completion/available/todo.completion.bash index b5517d8654..7281a7e893 100644 --- a/completion/available/todo.completion.bash +++ b/completion/available/todo.completion.bash @@ -1,2 +1,3 @@ +# shellcheck shell=bash _log_warning 'Bash completion for "todo.txt-cli" is now deprecated, as it used code with incompatible license. Please disable this completion and use the instructions from "todo.txt-cli" developers instead.' diff --git a/completion/available/travis.completion.bash b/completion/available/travis.completion.bash index 49d8f2cc92..eb3062beb4 100644 --- a/completion/available/travis.completion.bash +++ b/completion/available/travis.completion.bash @@ -1,10 +1,18 @@ # shellcheck shell=bash -if _command_exists travis -then - if [[ -s "${__TRAVIS_COMPLETION_SCRIPT:=${TRAVIS_CONFIG_PATH:-${HOME}/.travis}/travis.sh}" ]] - then - source "${__TRAVIS_COMPLETION_SCRIPT}" - fi - unset __TRAVIS_COMPLETION_SCRIPT +# Make sure travis is installed +if ! _binary_exists travis; then + _log_warning "Without '$_' installed, this completion won't be too useful." fi + +# Don't handle completion if it's already managed +if _completion_exists travis; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +if [[ -s "${_travis_bash_completion_script:=${TRAVIS_CONFIG_PATH:-${HOME}/.travis}/travis.sh}" ]]; then + # shellcheck disable=SC1090 + source "${_travis_bash_completion_script}" +fi +unset "${!_travis_bash_completion@}" diff --git a/completion/available/vault.completion.bash b/completion/available/vault.completion.bash index 9520f166b1..ed5f5d297a 100644 --- a/completion/available/vault.completion.bash +++ b/completion/available/vault.completion.bash @@ -1,7 +1,16 @@ # shellcheck shell=bash -cite "about-completion" about-completion "vault completion" -if _binary_exists vault; then - complete -C vault vault +# Make sure vault is installed +if ! _binary_exists vault; then + _log_warning "Without '$_' installed, this completion won't be too useful." + return 1 fi + +# Don't handle completion if it's already managed +if _completion_exists vault; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +complete -C vault vault diff --git a/completion/available/virsh.completion.bash b/completion/available/virsh.completion.bash index 6450b4a305..beab7f0b3c 100644 --- a/completion/available/virsh.completion.bash +++ b/completion/available/virsh.completion.bash @@ -1,2 +1,3 @@ +# shellcheck shell=bash _log_warning 'Bash completion for "virsh" is now deprecated, as it used code with incompatible license. Please disable this completion and use the instructions from "virsh" developers instead.' diff --git a/completion/available/wpscan.completion.bash b/completion/available/wpscan.completion.bash index 105468a356..27ea793e48 100644 --- a/completion/available/wpscan.completion.bash +++ b/completion/available/wpscan.completion.bash @@ -1,8 +1,17 @@ # shellcheck shell=bash -_command_exists wpscan || return +# Make sure wpscan is installed +if ! _binary_exists wpscan; then + _log_warning "Without '$_' installed, this completion won't be too useful." +fi -function __wpscan_completion() { +# Don't handle completion if it's already managed +if _completion_exists wpscan; then + _log_warning "completion already loaded - this usually means it is safe to stop using this completion" + return 0 +fi + +function __wpscan() { local _opt_ local OPTS=('--help' '--hh' '--version' '--url' '--ignore-main-redirect' '--verbose' '--output' '--format' '--detection-mode' '--scope' '--headers' '--user-agent' '--vhost' '--random-user-agent' '--user-agents-list' '--http-auth' '--max-threads' '--throttle' '--request-timeout' '--connect-timeout' '--disable-tlc-checks' '--proxy' '--proxy-auth' '--cookie-string' '--cookie-jar' '--cache-ttl' '--clear-cache' '--server' '--cache-dir' '--update' '--no-update' '--wp-content-dir' '--wp-plugins-dir' '--wp-version-detection' '--main-theme-detection' '--enumerate' '--exclude-content-based' '--plugins-list' '--plugins-detection' '--plugins-version-all' '--plugins-version-detection' '--themes-list' '--themes-detection' '--themes-version-all' '--themes-version-detection' '--timthumbs-list' '--timthumbs-detection' '--config-backups-list' '--config-backups-detection' '--db-exports-list' '--db-exports-detection' '--medias-detection' '--users-list' '--users-detection' '--passwords' '--usernames' '--multicall-max-passwords' '--password-attack' '--stealthy') COMPREPLY=() @@ -13,4 +22,4 @@ function __wpscan_completion() { done } -complete -F __wpscan_completion wpscan +complete -F __wpscan wpscan