]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
bash_completion: Do not auto complete obsolete and hidden cmds 35117/head
authorKotresh HR <khiremat@redhat.com>
Sat, 18 Apr 2020 18:33:37 +0000 (00:03 +0530)
committerVicente Cheng <freeze.bilsted@gmail.com>
Tue, 19 May 2020 06:08:34 +0000 (06:08 +0000)
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>
(cherry picked from commit 41082930f33fa43391986ac05394dbfff3b5dfd7)

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 6e24ed90233edb5498ff50baf084b4d922bbbab9..120057e5b61a4c31dc7df546a7ac1f740999be81 100755 (executable)
@@ -680,6 +680,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