[libvirt] [PATCH] virsh: Don't skip the first entry when the typed command share same prefix

Lin Ma posted 1 patch 5 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20180511091310.7245-1-lma@suse.com
Test syntax-check passed
tools/vsh.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[libvirt] [PATCH] virsh: Don't skip the first entry when the typed command share same prefix
Posted by Lin Ma 5 years, 10 months ago
Signed-off-by: Lin Ma <lma@suse.com>
---
 tools/vsh.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index f76076b164..1516e578d9 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -3495,11 +3495,11 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd)
     if (!(matches = vshReadlineCompletion(arg, 0, 0)))
         goto cleanup;
 
-    /* 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++)
+    for (iter = matches; *iter; iter++) {
+        if (iter == matches && matches[1])
+            continue;
         printf("%s\n", *iter);
+    }
 
     ret = true;
  cleanup:
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virsh: Don't skip the first entry when the typed command share same prefix
Posted by Michal Privoznik 5 years, 10 months ago
On 05/11/2018 11:13 AM, Lin Ma wrote:
> Signed-off-by: Lin Ma <lma@suse.com>
> ---
>  tools/vsh.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/vsh.c b/tools/vsh.c
> index f76076b164..1516e578d9 100644
> --- a/tools/vsh.c
> +++ b/tools/vsh.c
> @@ -3495,11 +3495,11 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd)
>      if (!(matches = vshReadlineCompletion(arg, 0, 0)))
>          goto cleanup;
>  
> -    /* 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++)
> +    for (iter = matches; *iter; iter++) {
> +        if (iter == matches && matches[1])
> +            continue;
>          printf("%s\n", *iter);
> +    }
>  
>      ret = true;
>   cleanup:
> 

Oops. The documentation failed me. Again.

ACKed and pushed. Thanks for catching this.

Michal

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