From: Eric Blake <eblake@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
Liviu Ionescu <ilg@livius.net>,
Leon Alrae <leon.alrae@imgtec.com>,
Matthew Fortune <Matthew.Fortune@imgtec.com>,
"christopher.covington@linaro.org"
<christopher.covington@linaro.org>
Subject: Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument
Date: Tue, 21 Apr 2015 11:22:01 -0600 [thread overview]
Message-ID: <55368739.5090000@redhat.com> (raw)
In-Reply-To: <CAFEAcA_xiqWVJyq2oHuCFqm6uoo3Dxrzj6AgtF=eZjFUDMMT-A@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2066 bytes --]
On 04/21/2015 10:54 AM, Peter Maydell wrote:
> On 21 April 2015 at 17:48, Eric Blake <eblake@redhat.com> wrote:
>> On 04/21/2015 09:55 AM, Peter Maydell wrote:
>>> If you want pure POSIX shell then it is slightly
>>> uglier as we have to invoke sed:
>>>
>>> argstr=""
>>> for arg in "$@"; do
>>> o=$(printf '%s.\n' "$arg" | sed s/,/,,/g)
>>> argstr=${argstr:+$argstr,}arg=${o%.}
>>> done
>>
>> It's possible to use IFS= and case to avoid the need to fork, while
>> still writing portable shell, but the solution then takes LOTS more
>> lines of code, so I'm not even going to bother to try writing it here.
>>
>> However, one thing this does NOT handle is an argument that is a literal
>> ','. That is, if I pass 'a', ',' and 'b' as my arguments, this script
>> results in $argstr being a,,,,b, which the qemu parser would read as a
>> single argument of 'a,,b' rather than the three intended arguments.
>
> Hmm? You get "arg=a,arg=,,,arg=b". Does the parser not read that
> the way I would expect?
D'oh. I missed the 'arg=' insertion.
>
>> In order to handle that, you'd need some sort of solution that requires
>> an unambiguous separation between arguments. For example,
>>
>> --semihosting-options opt=a,,,,b
>> vs.
>> --semihosting-options opt=a,opt=,,,opt=b
>
> The latter is what the script works with (except 'arg' rather
> than 'opt').
Indeed, we have an unambiguous representation already, and I just
overlooked it.
>
> Incidentally if you have a better idea for achieving the
> desired goal than this messing around with comma-escaping
> I would really like to know. I don't like either of the
> current two proposals very much :-(
Libvirt is already used to doing comma escaping; so while I may not like
the resulting syntax, I _do_ like the consistency factor (that is, it's
much easier to reuse the same mechanism everywhere than it is to invent
yet another mechanism).
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2015-04-21 17:22 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-01 13:18 [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument Leon Alrae
2015-04-01 15:21 ` Liviu Ionescu
2015-04-01 16:12 ` Matthew Fortune
2015-04-02 7:56 ` Leon Alrae
2015-04-02 8:29 ` Liviu Ionescu
2015-04-02 9:14 ` Leon Alrae
2015-04-02 10:36 ` Leon Alrae
2015-04-02 12:36 ` Liviu Ionescu
2015-04-02 14:27 ` Matthew Fortune
2015-04-02 16:47 ` Liviu Ionescu
2015-04-03 15:33 ` Liviu Ionescu
2015-04-08 16:20 ` Leon Alrae
2015-04-14 17:42 ` Liviu Ionescu
2015-04-15 9:09 ` Liviu Ionescu
2015-04-15 11:53 ` Leon Alrae
2015-04-15 12:02 ` Matthew Fortune
2015-04-15 12:06 ` Liviu Ionescu
2015-04-15 12:49 ` Leon Alrae
2015-04-15 16:08 ` Liviu Ionescu
2015-04-16 9:27 ` Leon Alrae
2015-04-17 17:45 ` Liviu Ionescu
2015-04-16 14:22 ` Peter Maydell
2015-04-21 13:34 ` Leon Alrae
2015-04-21 15:14 ` Liviu Ionescu
2015-04-21 15:55 ` Peter Maydell
2015-04-21 16:21 ` Liviu Ionescu
2015-04-21 16:23 ` Peter Maydell
2015-04-21 16:51 ` Liviu Ionescu
2015-04-21 17:50 ` Peter Maydell
2015-04-21 16:48 ` Eric Blake
2015-04-21 16:54 ` Peter Maydell
2015-04-21 17:22 ` Eric Blake [this message]
2015-04-21 17:49 ` Liviu Ionescu
2015-04-21 18:08 ` Liviu Ionescu
2015-04-23 11:55 ` Leon Alrae
2015-04-23 12:07 ` Liviu Ionescu
2015-04-01 15:45 ` Christopher Covington
2015-04-01 16:24 ` Liviu Ionescu
2015-04-04 15:20 ` Liviu Ionescu
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=55368739.5090000@redhat.com \
--to=eblake@redhat.com \
--cc=Matthew.Fortune@imgtec.com \
--cc=christopher.covington@linaro.org \
--cc=ilg@livius.net \
--cc=leon.alrae@imgtec.com \
--cc=peter.maydell@linaro.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.