From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJmm1-00082N-GN for qemu-devel@nongnu.org; Wed, 11 Sep 2013 11:56:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJmlv-0005pZ-Lw for qemu-devel@nongnu.org; Wed, 11 Sep 2013 11:56:09 -0400 Message-ID: <52309288.8000100@redhat.com> Date: Wed, 11 Sep 2013 09:55:52 -0600 From: Eric Blake MIME-Version: 1.0 References: <1378906912-14015-1-git-send-email-gabriel@kerneis.info> <523077CE.6070303@redhat.com> <20130911144230.GA15227@kerneis.info> <523083EF.7050203@redhat.com> In-Reply-To: <523083EF.7050203@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Hta0hBwENlip1fiTXa8L67swbXXT0P04H" Subject: Re: [Qemu-devel] [PATCH] Quote extra_cflags in config-host.mak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-trivial@nongnu.org, Peter Maydell , Gabriel Kerneis , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Hta0hBwENlip1fiTXa8L67swbXXT0P04H Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/11/2013 08:53 AM, Paolo Bonzini wrote: >=20 > printf "# Configured with:" >> $config_host_mak > printf " '%s'" "$0" "$@" >> $config_host_mak >=20 > Something like >=20 > for arg in "$0" "$@"; do > quoted_arg=3D$(echo "$i" | sed 's/[$\\"]/\\&/g') Won't work as written: mismatch between $arg vs. $i. That missed ` - but do we expect anyone to pass a literal ` as one of their arguments? Also, it strips any literal trailing newlines in the arguments. > printf ' "%s"' "$quoted_arg" > done >> $config_host_mak >=20 > could replace the second line. Adding Eric Blake in case he knows some= > extra trick. Nope, no good portable tricks for this. But to address the (corner case) issues I mentioned above, it might be worth using '' rather than "" quoting; as well as embed a trailing space to guarantee no trailing newline: for arg in "$0" "$@"; do quoted_arg=3D$(echo "$arg " | sed "s/'/'\\''/g') printf "'%s'" "$quoted_arg" done >> $config_host_mak if you don't mind a trailing space in the output file. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Hta0hBwENlip1fiTXa8L67swbXXT0P04H Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSMJKIAAoJEKeha0olJ0NqLA4H/jYs722QNkoze7GxobkXJNyV bmsnZrvYp5eppJT7Tue7KTv/KFMPMDib6YSkh1L39ayjYTorRB+6xMoAeVJXFeHR 94U3ZSMCTLak29ZEW8hH6CUGC5XXtHWMeCCU9EBxbhL5wu9jleWQjgLRHyN9C4nl qSI79w5SXtPgJeGqqIjz7Y35A0pfHMaNA/lHqyb215At/IqBlom6zftXfOnSPg9F oPRsGjMWwSVEhjvYwYhvP+gEV08wQ1P4NDUA+qoBi1rrkJURnV/9AJOQw5tF23n4 yO3AqwXQX1c3pcuvjSfiNEpUL+dmi7y++7p/h68bqmWXUaUyaIiR0NOKEo6j5HU= =oGG9 -----END PGP SIGNATURE----- --Hta0hBwENlip1fiTXa8L67swbXXT0P04H--