mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
Allow bash-completion to work with full-path executable
This commit is contained in:
parent
04d02e3184
commit
2a20bcba18
1 changed files with 7 additions and 1 deletions
|
@ -182,9 +182,13 @@ __handle_command()
|
||||||
local next_command
|
local next_command
|
||||||
if [[ -n ${last_command} ]]; then
|
if [[ -n ${last_command} ]]; then
|
||||||
next_command="_${last_command}_${words[c]//:/__}"
|
next_command="_${last_command}_${words[c]//:/__}"
|
||||||
|
else
|
||||||
|
if [[ $c -eq 0 ]]; then
|
||||||
|
next_command="_$(basename ${words[c]//:/__})"
|
||||||
else
|
else
|
||||||
next_command="_${words[c]//:/__}"
|
next_command="_${words[c]//:/__}"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
c=$((c+1))
|
c=$((c+1))
|
||||||
__debug "${FUNCNAME}: looking for ${next_command}"
|
__debug "${FUNCNAME}: looking for ${next_command}"
|
||||||
declare -F $next_command >/dev/null && $next_command
|
declare -F $next_command >/dev/null && $next_command
|
||||||
|
@ -201,6 +205,8 @@ __handle_word()
|
||||||
__handle_flag
|
__handle_flag
|
||||||
elif __contains_word "${words[c]}" "${commands[@]}"; then
|
elif __contains_word "${words[c]}" "${commands[@]}"; then
|
||||||
__handle_command
|
__handle_command
|
||||||
|
elif [[ $c -eq 0 ]] && __contains_word "$(basename ${words[c]})" "${commands[@]}"; then
|
||||||
|
__handle_command
|
||||||
else
|
else
|
||||||
__handle_noun
|
__handle_noun
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue