From: Lin Ma Date: Tue, 8 May 2018 14:20:31 +0000 (+0800) Subject: virsh: Conditionally Ignore the first entry in list of completions X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=55948988e896f457b654daff66bc5953f344c996;p=libvirt.git virsh: Conditionally Ignore the first entry in list of completions 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 des desc destroy or $ virsh domblklist --d --d --details --domain This patch fixes the above issue. Signed-off-by: Lin Ma Signed-off-by: Michal Privoznik --- diff --git a/tools/vsh.c b/tools/vsh.c index 73ec007e56..68f3cd99f9 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -3493,7 +3493,10 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd) if (!(matches = vshReadlineCompletion(arg, 0, 0))) goto cleanup; - for (iter = matches; *iter; iter++) + /* According to rl_completion_matches documentation, the + * first entry in @matches array is some dummy substitution + * string for @arg. Skip it. */ + for (iter = &matches[1]; *iter; iter++) printf("%s\n", *iter); ret = true;