On Fri, May 04, 2018 at 17:25:23 +0800, Lin Ma wrote:
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(a)suse.com>
---
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++) {
Fails 'make syntax-check':
Spacing around '=' or '==':
tools/vsh.c:3499: for (n =0, iter = matches; *iter; iter++, n++) {
maint.mk: incorrect formatting
+ if (n == 0 && matches[1])
+ continue;
printf("%s\n", *iter);
+ }
ret = true;
cleanup:
--
2.15.1
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list