Qualify custom bash func name (#730)
* Qualify custom bash func name - fixes issue where multiple cobra apps using custom bash completion would have their __custom_func collide - support fallback to plain __custom_func to maintain compatibility #694 * Improve tests for bash completion __custom_func - check for the correct number of occurrences of function name #694
This commit is contained in:
@ -129,7 +129,13 @@ __%[1]s_handle_reply()
|
||||
fi
|
||||
|
||||
if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
|
||||
declare -F __custom_func >/dev/null && __custom_func
|
||||
if declare -F __%[1]s_custom_func >/dev/null; then
|
||||
# try command name qualified custom func
|
||||
__%[1]s_custom_func
|
||||
else
|
||||
# otherwise fall back to unqualified for compatibility
|
||||
declare -F ___custom_func >/dev/null && __custom_func
|
||||
fi
|
||||
fi
|
||||
|
||||
# available in bash-completion >= 2, not always present on macOS
|
||||
|
Reference in New Issue
Block a user