[PATCH 02/12] virsh: Conditionally Ignore the first entry in list of completions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The first entry in the returned array is the substitution for TEXT. It
causes unnecessary output if other commands or options share the same
prefix, e.g.

$ virsh des<TAB><TAB>
des      desc     destroy

or

$ virsh domblklist --d<TAB><TAB>
--d        --details  --domain

This patch fixes the above issue.

Signed-off-by: Lin Ma <lma@xxxxxxxx>
---
 tools/vsh.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index 73ec007e56..38058c874a 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -3458,6 +3458,7 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd)
     const vshCmdOpt *opt = NULL;
     char **matches = NULL, **iter;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
+    int n;
 
     if (vshCommandOptStringQuiet(ctl, cmd, "string", &arg) <= 0)
         goto cleanup;
@@ -3493,8 +3494,11 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd)
     if (!(matches = vshReadlineCompletion(arg, 0, 0)))
         goto cleanup;
 
-    for (iter = matches; *iter; iter++)
+    for (n =0, iter = matches; *iter; iter++, n++) {
+        if (n == 0 && matches[1])
+            continue;
         printf("%s\n", *iter);
+    }
 
     ret = true;
  cleanup:
-- 
2.15.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux