From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ydg6C-0002pp-Iw for qemu-devel@nongnu.org; Thu, 02 Apr 2015 10:28:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ydg67-00005j-Sb for qemu-devel@nongnu.org; Thu, 02 Apr 2015 10:28:00 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:12832) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ydg67-0008WT-L8 for qemu-devel@nongnu.org; Thu, 02 Apr 2015 10:27:55 -0400 From: Matthew Fortune Date: Thu, 2 Apr 2015 14:27:52 +0000 Message-ID: <6D39441BF12EF246A7ABCE6654B023532101BA54@LEMAIL01.le.imgtec.org> 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> In-Reply-To: <1C30C43D-CD89-4EBF-991A-9CC53019ED7B@livius.net> Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: Liviu Ionescu , Leon Alrae Cc: "peter.maydell@linaro.org" , "qemu-devel@nongnu.org" , "christopher.covington@linaro.org" Liviu Ionescu writes: > > On 02 Apr 2015, at 13:36, Leon Alrae wrote: > > > >> How would you pass arguments containing whitespaces via > >> -semihosting-config cmdline without having to reinvent shell within > QEMU? > > > > I missed the fact that you already provided the implementation for > > this below... >=20 >=20 > for completeness: >=20 > ilg-mbp:gnuarmeclipse-qemu.git ilg$ "/Applications/GNU ARM > Eclipse/QEMU/2.2.91-201504021111-dev/bin/qemu-system-gnuarmeclipse" - > verbose -machine STM32-H103 -gdb tcp::1234 -semihosting-config > enable=3Don,target=3Dnative,cmdline=3D'n "1 a" 2 3' I see here that you have switched quotes because you know that you are providing a double quoted argument within the string. The root of all argument passing issues tends to boil down to how to quote and or escape characters appropriately. Because you know the arguments you can quote correctly but for an unknown user-provided set of arguments (where they do not know how their arguments will flow down to an application) then the appropriate quoting and escaping becomes harder. The problem characters are obviously single and double quotes. Having different quoting rules for any of the layers between a user and the emulated program is always going to cause some confusion so when quoting is necessary I have always found that following the standard argument passing rules of the native application is the least problematic. qemu-system... -semihosting-config "arg=3Dfoo bar" -semihosting-config "arg= =3Dsecond" This should give an argv of ["foo bar", "second"] I'd propose that the cmdline option is retained for those cases that do not need to cope with spaces (and also can avoid commas in the cmdline or have them automatically doubled) and introduce arg=3D as a more flexible case such that both commas and spaces are naturally handled (the arg=3D just needs chopping off the start). This could be implemented by saying that as soon as the parser sees arg=3D then the rest of the string is one argument. The comma issue for cmdline could be avoided like this too by mandating that cmdline is the last part of the config options. Just my thoughts :-) Matthew