From fb6e05d91528bf83175f92b5481d0ee6d6a88c39 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sun, 19 Sep 2021 10:39:19 -0700 Subject: [PATCH] completions/sqlmap: use `_command_exists` Addresses bash-it/bash-it#1632 --- completion/available/sqlmap.completion.bash | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/completion/available/sqlmap.completion.bash b/completion/available/sqlmap.completion.bash index 16addf85..213dd817 100644 --- a/completion/available/sqlmap.completion.bash +++ b/completion/available/sqlmap.completion.bash @@ -1,21 +1,22 @@ -#!/bin/bash +# shellcheck shell=bash # ---------------------------------------------------------------------------+ # | -# Thanks to Alexander Korznikov | +# Thanks to Alexander Korznikov | # http://www.korznikov.com/2014/12/bash-tab-completion-for-awesome-tool.html | # | # ---------------------------------------------------------------------------+ -if command -v sqlmap > /dev/null; then +if _command_exists sqlmap +then - _sqlmap() + function _sqlmap() { local cur prev COMPREPLY=() - cur=$(_get_cword) - prev=$(_get_pword) + cur="$(_get_cword)" + prev="$(_get_pword)" case $prev in @@ -143,7 +144,7 @@ if command -v sqlmap > /dev/null; then --mobile --page-rank --purge-output --smart \ --sqlmap-shell --wizard ' COMPREPLY=( $( \ - (while read -d ' ' i; do + (while read -d ' ' i; do [[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] && continue # flatten array with spaces on either side, @@ -152,7 +153,7 @@ if command -v sqlmap > /dev/null; then COMPREPLY=" ${COMPREPLY[@]} " # remove word from list of completions COMPREPLY=( ${COMPREPLY/ ${i%% *} / } ) - done + done printf '%s ' "${COMPREPLY[@]}") <<<"${COMP_WORDS[@]}" ) )