[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-arg
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument |
Date: |
Tue, 21 Apr 2015 11:22:01 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
On 04/21/2015 10:54 AM, Peter Maydell wrote:
> On 21 April 2015 at 17:48, Eric Blake <address@hidden> 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
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, (continued)
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Peter Maydell, 2015/04/16
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Leon Alrae, 2015/04/21
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Liviu Ionescu, 2015/04/21
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Peter Maydell, 2015/04/21
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Liviu Ionescu, 2015/04/21
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Peter Maydell, 2015/04/21
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Liviu Ionescu, 2015/04/21
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Peter Maydell, 2015/04/21
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Eric Blake, 2015/04/21
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Peter Maydell, 2015/04/21
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument,
Eric Blake <=
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Liviu Ionescu, 2015/04/21
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Liviu Ionescu, 2015/04/21
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Leon Alrae, 2015/04/23
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Liviu Ionescu, 2015/04/23
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Christopher Covington, 2015/04/01
- Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument, Liviu Ionescu, 2015/04/04