From: Kashyap Chamarthy <kchamart@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
qemu-devel@nongnu.org, armbru@redhat.com,
"Cleber Rosa" <crosa@redhat.com>,
ehabkost@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qmp-shell: fix nested json regression
Date: Wed, 6 Feb 2019 11:48:51 +0100 [thread overview]
Message-ID: <20190206104851.GT5349@paraplu.home> (raw)
In-Reply-To: <781b71d9-f045-ffa9-3674-f6222f6e7e0b@redhat.com>
On Tue, Feb 05, 2019 at 08:44:12PM -0500, John Snow wrote:
> On 2/5/19 8:49 AM, Marc-André Lureau wrote:
[...]
> > Replace with a regexp to split while respecting quoted strings and preserving quotes:
> >
> > re.findall(r'''(?:[^\s"']|"(?:\\.|[^"])*"|'(?:\\.|[^'])*')+''', cmd)
> > ['blockdev-create',
> > 'job-id="job0 foo"',
> > 'options={"driver":"qcow2","size":16384,"file":{"driver":"file","filename":"foo.qcow2"}}']
> >
> > Fixes: fcfab7541 ("qmp-shell: learn to send commands with quoted arguments")
> > Reported-by: Kashyap Chamarthy <kchamart@redhat.com>
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > scripts/qmp/qmp-shell | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
> > index 770140772d..813dd68232 100755
> > --- a/scripts/qmp/qmp-shell
> > +++ b/scripts/qmp/qmp-shell
> > @@ -74,7 +74,7 @@ import sys
> > import os
> > import errno
> > import atexit
> > -import shlex
> > +import re
> >
> > class QMPCompleter(list):
> > def complete(self, text, state):
> > @@ -220,7 +220,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
> >
> > < command-name > [ arg-name1=arg1 ] ... [ arg-nameN=argN ]
> > """
> > - cmdargs = shlex.split(cmdline)
> > + cmdargs = re.findall(r'''(?:[^\s"']|"(?:\\.|[^"])*"|'(?:\\.|[^'])*')+''', cmdline)
>
> It might really be nice to have a comment briefly explaining the regex.
> This is pretty close to symbol soup.
Yeah, a little comment explaining it would be nice.
And thanks for the fix, indeed. FWIW:
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
> Though I suppose we are approaching the limits of what this hacky little
> debug script can do for us...
It is good enough for 80% of the cases. :-)
--
/kashyap
next prev parent reply other threads:[~2019-02-06 10:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-05 13:49 [Qemu-devel] [PATCH] qmp-shell: fix nested json regression Marc-André Lureau
2019-02-06 1:44 ` John Snow
2019-02-06 10:48 ` Kashyap Chamarthy [this message]
2019-02-06 11:09 ` Kashyap Chamarthy
2019-03-08 22:50 ` John Snow
2019-03-09 9:01 ` Markus Armbruster
2019-03-11 13:27 ` Eduardo Habkost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190206104851.GT5349@paraplu.home \
--to=kchamart@redhat.com \
--cc=armbru@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=jsnow@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).