On Thu, Oct 13, 2011 at 11:03:05PM +0200, Guido Günther wrote:
> ---
>  tools/virsh.c |   25 +++++--------------------
>  1 files changed, 5 insertions(+), 20 deletions(-)

I just noticed that this breaks the testsuite for two reasons:

cmdEcho emits '' in case of an *arg == 0 and it also allows for --shell
--xml which I didn't think is useful at first but it actually is. I'll
come up with a new version.

Cheers,
 -- Guido

> 
> diff --git a/tools/virsh.c b/tools/virsh.c
> index bcf0603..fe1a224 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -12340,27 +12340,12 @@ cmdEcho (vshControl *ctl ATTRIBUTE_UNUSED, const 
> vshCmd *cmd)
>          arg = opt->data;
>          if (count)
>              virBufferAddChar(&buf, ' ');
> -        /* Add outer '' only if arg included shell metacharacters.  */
> -        if (shell &&
> -            (strpbrk(arg, "\r\t\n !\"#$&'()*;<>?[\\]^`{|}~") || !*arg)) {
> -            virBufferAddChar(&buf, '\'');
> -            close_quote = true;
> -        }
> -        if (xml) {
> +        if (xml)
>              virBufferEscapeString(&buf, "%s", arg);
> -        } else {
> -            if (shell && (q = strchr(arg, '\''))) {
> -                do {
> -                    virBufferAdd(&buf, arg, q - arg);
> -                    virBufferAddLit(&buf, "'\\''");
> -                    arg = q + 1;
> -                    q = strchr(arg, '\'');
> -                } while (q);
> -            }
> -            virBufferAdd(&buf, arg, strlen(arg));
> -        }
> -        if (close_quote)
> -            virBufferAddChar(&buf, '\'');
> +        else if (shell)
> +            virBufferEscapeShell(&buf, arg);
> +        else
> +            virBufferAdd(&buf, arg, -1);
>          count++;
>      }
>  
> -- 
> 1.7.6.3

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

Reply via email to