From 75bfce75c2d7255eebf45dc7dbe935e8019916cc Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Thu, 18 Aug 2022 17:01:06 +0200 Subject: [PATCH] scripts/bash-completion: Extract all rpc methods Currently we extract these methods from rpc.py's --help or from rpc_get_methods() in case there's a SPDK application running in the background. This, however, results in a list missing some basic methods that rpc_get_methods() simply doesn't include, e.g. save_subsystem_config(). To make sure we always have a complete list use both, --help and the rpc_get_methods() together. Signed-off-by: Michal Berger Change-Id: Ie73917b74860cac13056bea9babc7f7b57e39b3a Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14115 Tested-by: SPDK CI Jenkins Reviewed-by: Krzysztof Karas Community-CI: Broadcom CI Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- scripts/bash-completion/spdk | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/scripts/bash-completion/spdk b/scripts/bash-completion/spdk index da1f2834c..99c3c1858 100644 --- a/scripts/bash-completion/spdk +++ b/scripts/bash-completion/spdk @@ -45,13 +45,11 @@ _get_default_rpc_methods() { done < <(_get_help "$1" 2> /dev/null) } -_get_supported_methods() { +_get_rpc_methods() { local method methods - if ! methods=($("$1" -s "$rpc_sock" rpc_get_methods 2> /dev/null)); then - _get_default_rpc_methods "$1" - return 0 - fi + _get_default_rpc_methods "$1" + methods=($("$1" -s "$rpc_sock" rpc_get_methods 2> /dev/null)) || return 0 ((${#methods[@]} > 0)) || return 0 # Kill the json flavor @@ -207,11 +205,7 @@ _rpc() { local -A rpc_methods=() _set_rpc_sock - if [[ -S $rpc_sock ]]; then - _get_supported_methods "$rpc" - else - _get_default_rpc_methods "$rpc" - fi + _get_rpc_methods "$rpc" if method=$(_method_in_words); then COMPREPLY=($(compgen -W '$(_get_help_rpc_method "$rpc" "$method")' -- "$cur"))