From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkbMI-0007yh-OE for qemu-devel@nongnu.org; Tue, 21 Apr 2015 12:49:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YkbMF-0005UO-FE for qemu-devel@nongnu.org; Tue, 21 Apr 2015 12:49:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkbMF-0005UA-7n for qemu-devel@nongnu.org; Tue, 21 Apr 2015 12:49:11 -0400 Message-ID: <55367F7B.4080303@redhat.com> Date: Tue, 21 Apr 2015 10:48:59 -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> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="b2300KBFx0Lnr2bb7IRsslJ8v5RlgfrUN" 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 , Liviu Ionescu Cc: "christopher.covington@linaro.org" , Leon Alrae , Matthew Fortune , "qemu-devel@nongnu.org" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --b2300KBFx0Lnr2bb7IRsslJ8v5RlgfrUN Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: >=20 > 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 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. In order to handle that, you'd need some sort of solution that requires an unambiguous separation between arguments. For example, --semihosting-options opt=3Da,,,,b vs. --semihosting-options opt=3Da,opt=3D,,,opt=3Db would be unambiguous representations of 1 vs. 3 options. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --b2300KBFx0Lnr2bb7IRsslJ8v5RlgfrUN 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/ iQEcBAEBCAAGBQJVNn98AAoJEKeha0olJ0NqPGYH+wZWfQLGFnvC/wxFLK3dTaoD +ppYNPxxx0VtaZx6T9/+auK7zhHz4AX99YDnxxfYfu25GJQ/KnYE2yGV19YaCyZU +jWcWlS3f/T8pgPJOkFaqWgDFW+RiDWaAi7vHDUGcz73Qjpa3SLmlKeOJtkwM8GC aV8+HNl6dSCrylcYcFdZoFfaObBxsukvwOIFeJie5YY+L20XyzxzM6NWNfpDYQeF 4BZnlL29EaDIY9ud1E+AT37zmskAcL/1co+tMJ8IDxC2XD4z3j9kGvxdMNMx5GE5 xvkiH8+AfltCB7/fZcmK7GHtfyDcelTTDnCnYLrHOl4PbWFwWUiO4qQJMbWNysI= =Sr+a -----END PGP SIGNATURE----- --b2300KBFx0Lnr2bb7IRsslJ8v5RlgfrUN--