From de58fdd73fa6316626080c8b73df3b9a669aa1da Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sun, 19 Sep 2021 21:57:21 -0700 Subject: [PATCH] plugins/autojump: use `_command_exists` Addresses bash-it/bash-it#1632 --- clean_files.txt | 1 + plugins/available/autojump.plugin.bash | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/clean_files.txt b/clean_files.txt index 173995c5..26496237 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -77,6 +77,7 @@ completion/available/wpscan.completion.bash # plugins # plugins/available/alias-completion.plugin.bash +plugins/available/autojump.plugin.bash plugins/available/basher.plugin.bash plugins/available/cmd-returned-notify.plugin.bash plugins/available/docker-machine.plugin.bash diff --git a/plugins/available/autojump.plugin.bash b/plugins/available/autojump.plugin.bash index 7e6df7fc..dc8fbbb4 100644 --- a/plugins/available/autojump.plugin.bash +++ b/plugins/available/autojump.plugin.bash @@ -1,12 +1,15 @@ +# shellcheck shell=bash cite about-plugin about-plugin 'Autojump configuration, see https://github.com/wting/autojump for more details' # Only supports the Homebrew variant, Debian and Arch at the moment. # Feel free to provide a PR to support other install locations if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" ]]; then - . "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" -elif command -v dpkg &>/dev/null && dpkg -s autojump &>/dev/null ; then - . "$(dpkg-query -S autojump.sh | cut -d' ' -f2)" -elif command -v pacman &>/dev/null && pacman -Q autojump &>/dev/null ; then - . "$(pacman -Ql autojump | grep autojump.sh | cut -d' ' -f2)" + source "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" +elif _command_exists dpkg && dpkg -s autojump &> /dev/null; then + # shellcheck disable=SC1090 + source "$(dpkg-query -S autojump.sh | cut -d' ' -f2)" +elif _command_exists pacman && pacman -Q autojump &> /dev/null; then + # shellcheck disable=SC1090 + source "$(pacman -Ql autojump | grep autojump.sh | cut -d' ' -f2)" fi