]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
bash_completion: Do not auto complete obsolete and hidden cmds
authorKotresh HR <khiremat@redhat.com>
Sat, 18 Apr 2020 18:33:37 +0000 (00:03 +0530)
committerKotresh HR <khiremat@redhat.com>
Fri, 24 Apr 2020 09:42:53 +0000 (15:12 +0530)
This patch fixes two things.

1. Do not auto complete obsolete and hidden cmds.
2. sub command completions often failed due to the
   use of associative arrays which does not keep the
   order. Hence used non-associative arrays.

Fixes: https://tracker.ceph.com/issues/45141
Signed-off-by: Kotresh HR <khiremat@redhat.com>
src/bash_completion/ceph
src/ceph.in

index beec700e854c93e99fc41c76b1b0225d5bc50204..d28c8a4fa76e83740bfce6b76bb4dfa032cebe01 100644 (file)
@@ -27,7 +27,7 @@ _ceph()
        COMPREPLY=( $(compgen -W "${options_noarg} ${options_arg}" -- $cur) )
        return 0
     fi
-    declare -A hint_args
+    declare -a hint_args
     for (( i=1 ; i<cnt ; i++ ))
     do
        #skip this word if it is option
index 369b9696540cb59b7085408ce6b6bd5e374fee1b..13929a4cca8d1610527495711b3db56ec24ca224 100755 (executable)
@@ -679,6 +679,9 @@ def complete(sigdict, args, target):
     match_count = 0
     comps = []
     for cmdtag, cmd in sigdict.items():
+        flags = cmd.get('flags', 0)
+        if flags & (Flag.OBSOLETE | Flag.HIDDEN):
+            continue
         sig = cmd['sig']
         j = 0
         # iterate over all arguments, except last one