diff --git a/scripts/bash-completion/spdk b/scripts/bash-completion/spdk index 3f884f9df..a7cf5bc39 100644 --- a/scripts/bash-completion/spdk +++ b/scripts/bash-completion/spdk @@ -25,11 +25,6 @@ _get_help_pos() { } _get_default_rpc_methods() { - if [[ -S $rpc_sock ]]; then - _get_supported_methods "$1" - return 0 - fi - local aliases method names # Don't squash whitespaces, slurp the entire line while read -r; do @@ -53,7 +48,10 @@ _get_default_rpc_methods() { _get_supported_methods() { local method methods - mapfile -t methods < <("$1" -s "$rpc_sock" rpc_get_methods 2> /dev/null) + if ! methods=($("$1" -s "$rpc_sock" rpc_get_methods 2> /dev/null)); then + _get_default_rpc_methods "$1" + return 0 + fi ((${#methods[@]} > 0)) || return 0 # Kill the json flavor @@ -209,7 +207,11 @@ _rpc() { local -A rpc_methods=() _set_rpc_sock - _get_default_rpc_methods "$rpc" + if [[ -S $rpc_sock ]]; then + _get_supported_methods "$rpc" + else + _get_default_rpc_methods "$rpc" + fi if method=$(_method_in_words); then COMPREPLY=($(compgen -W '$(_get_help_rpc_method "$rpc" "$method")' -- "$cur"))