From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYGCo-00007b-Se for qemu-devel@nongnu.org; Thu, 10 Apr 2014 10:43:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WYGCk-0005AY-Bn for qemu-devel@nongnu.org; Thu, 10 Apr 2014 10:43:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55612) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYGCk-0005AM-4U for qemu-devel@nongnu.org; Thu, 10 Apr 2014 10:43:50 -0400 Message-ID: <5346AE20.4040903@redhat.com> Date: Thu, 10 Apr 2014 08:43:44 -0600 From: Eric Blake MIME-Version: 1.0 References: <10015a278ac01aa8f6848bf89d433c91e3184b76.1397097046.git.jcody@redhat.com> <20140410075357.GF22890@T430.nay.redhat.com> <20140410125356.GD4859@localhost.localdomain> In-Reply-To: <20140410125356.GD4859@localhost.localdomain> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Jjn5dnTo16fShcvXhCgeouWTxwkcwKcoo" Subject: Re: [Qemu-devel] [PATCH v2 4/5] block: qemu-iotests - fix image cleanup when using spaced pathnames List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody , Fam Zheng Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, benoit@irqsave.net This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Jjn5dnTo16fShcvXhCgeouWTxwkcwKcoo Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 04/10/2014 06:53 AM, Jeff Cody wrote: >>> +++ b/tests/qemu-iotests/common.rc >>> @@ -178,10 +178,10 @@ _rm_test_img() >>> local img=3D$1 >> >> Since we are quoting $img, should we quote $1 as well? >> >=20 > I believe not, because variable assignment won't undergo all the shell > expansions. Notably, in variable assignment word splitting is not > performed on the parameter expansion on the argument immediately to the= > right of the '=3D'. Quote removal, however, will still be performed. = So > img=3D$1 and img=3D"$1" are identical once processed. Ooh, tricky. You are correct that in isolation: img=3D$1 img=3D"$1" are semantically identical, no matter what $1 contains, across ALL shells. However, that's not the code you wrote above. local img=3D$1 is not POSIX (yet - although there has been some effort in the POSIX working group to standardize some form of local variables while still allowing for the fact that bash and ksh implemented scoping of local variables differently). But 'local' is similar to 'export'; and observe the difference when using 'export' between dash and bash: $ dash -c 'set "a b"; export a=3D$1 b=3D"$1"; echo "$a.$b"' a.a b $ bash -c 'set "a b"; export a=3D$1 b=3D"$1"; echo "$a.$b"' a b.a b Here, the shell word a=3D$1 is semantically NOT a raw assignment, but rather an argument to 'export', and arguments DO undergo word splitting in the current wording of POSIX. There was a recent bug report stating that the dash behavior (which is strictly POSIX) is undesirable, and that the bash/ksh behavior of export, while not strictly compliant with the POSIX 2008 wording, is nicer; so the next version of POSIX will be amended to add a definition of a 'declaration utility' which can evaluate (some) arguments in assignment context. 'export' is one such declaration utility, 'local' (if it gets standardized) would be another: http://austingroupbugs.net/view.php?id=3D351 But even with the notion of an assignment-context argument added to a future version of POSIX, the reality is that given the present standard, it's safer to either use "" to ensure no word splitting: local img=3D"$1" or to rewrite things across two statements to avoid relying on whether assignment-context arguments work the way you want: local img img=3D$1 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Jjn5dnTo16fShcvXhCgeouWTxwkcwKcoo 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTRq4gAAoJEKeha0olJ0NqAR4H/3q3EliZV19D0/gyDQrFKsDZ Pi6omRaGVm2cMyYB/R4N7fcjdN3Yc/FSsb+H27kUHCYvkgiImtCTqdWjybjmhBpa 7zZhOKy6uDlCBELUaFDGhRfJ9aAjsM15rFHTjotQQTMaZzYpEKRqTLHwVHT7lQbn EwyUcxj9mXTbPLavnZnCDSBHf8drsdqILvMsiqkFGffMffuajd2A/NEE/dawv1pk v7n1q40mapuKMlwzg4BJqUX7kyxOfbEoxfqB2enuorqga7LEUoTdGJQ1fRwzg1v8 KdfFxw0PjNZ5HApw4lrGeBf5Dws02SKfQReciggVtw6W5AIOGjYxvOq3Ci7vBaM= =QEwm -----END PGP SIGNATURE----- --Jjn5dnTo16fShcvXhCgeouWTxwkcwKcoo--