From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ykbs8-0003BZ-AM for qemu-devel@nongnu.org; Tue, 21 Apr 2015 13:22:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ykbs4-0007zq-3A for qemu-devel@nongnu.org; Tue, 21 Apr 2015 13:22:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46183) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ykbs3-0007zi-RP for qemu-devel@nongnu.org; Tue, 21 Apr 2015 13:22:04 -0400 Message-ID: <55368739.5090000@redhat.com> Date: Tue, 21 Apr 2015 11:22:01 -0600 From: Eric Blake MIME-Version: 1.0 References: <1427894283-31953-1-git-send-email-leon.alrae@imgtec.com> <9DE872C8-4AE3-48FC-B4A1-61ADE4DB7F32@livius.net> <551CF623.7040506@imgtec.com> <551D086D.9010604@imgtec.com> <551D1BC2.10408@imgtec.com> <1C30C43D-CD89-4EBF-991A-9CC53019ED7B@livius.net> <6D39441BF12EF246A7ABCE6654B023532101BA54@LEMAIL01.le.imgtec.org> <1741D364-48FC-4682-B660-82A5B48F8DE4@livius.net> <55255556.8020504@imgtec.com> <2A76D025-D3C9-4023-B48B-F6870998C99A@livius.net> <553651ED.9080209@imgtec.com> <3CDEFB52-C1C6-4012-AEFA-0630706AAF74@livius.net> <55367F7B.4080303@redhat.com> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="f4P5WHxhOQLwa7o4v53ssnOMRN5QEpxmH" Subject: Re: [Qemu-devel] [RFC PATCH] vl.c: add -semihosting-config "arg" sub-argument List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: "qemu-devel@nongnu.org" , Liviu Ionescu , Leon Alrae , Matthew Fortune , "christopher.covington@linaro.org" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --f4P5WHxhOQLwa7o4v53ssnOMRN5QEpxmH Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/21/2015 10:54 AM, Peter Maydell wrote: > On 21 April 2015 at 17:48, Eric Blake 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=3D"" >>> for arg in "$@"; do >>> o=3D$(printf '%s.\n' "$arg" | sed s/,/,,/g) >>> argstr=3D${argstr:+$argstr,}arg=3D${o%.} >>> done >> >> It's possible to use IFS=3D 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 liter= al >> ','. 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. >=20 > Hmm? You get "arg=3Da,arg=3D,,,arg=3Db". Does the parser not read that > the way I would expect? D'oh. I missed the 'arg=3D' insertion. >=20 >> In order to handle that, you'd need some sort of solution that require= s >> an unambiguous separation between arguments. For example, >> >> --semihosting-options opt=3Da,,,,b >> vs. >> --semihosting-options opt=3Da,opt=3D,,,opt=3Db >=20 > 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. >=20 > 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). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --f4P5WHxhOQLwa7o4v53ssnOMRN5QEpxmH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVNoc5AAoJEKeha0olJ0NqT2wH/3yt7EouKAkWDrXWL2GPILEJ K3a0paNEGTQtIM3tQooqGF8CKGmJMY9VaZu0DAmC2NUiHh48P+wtNjuVnRl+oNMh bLqgSO/QizMsTLZSpoSIYHYqfz6aHvaHQj7jVD4RhVzEjRbUiLhltsNOHKCzlOFl o4gdDOQwkeo0Nzb2OlEJZo4kuVwVJdtuobeerGyq6v+wPpwCW6LAKmP6IveO/abT o7Yf4IChG2T7Kky9pj0iSNvMiMfZJ9m43/44F8LLzq0D0xGOp+l6QN0kkhupyVGL 05qSBFhQhAV8hKKEKl3p8xzDf0cNoXj8+jYLVMT3dKjutSrD1gOmjD6fnSG1pU8= =xhfy -----END PGP SIGNATURE----- --f4P5WHxhOQLwa7o4v53ssnOMRN5QEpxmH--