From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlJla-0002yR-Vs for qemu-devel@nongnu.org; Fri, 16 May 2014 11:09:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WlJlV-0006bm-WA for qemu-devel@nongnu.org; Fri, 16 May 2014 11:09:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1808) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlJlV-0006bd-Jp for qemu-devel@nongnu.org; Fri, 16 May 2014 11:09:41 -0400 Message-ID: <53762A32.1070407@redhat.com> Date: Fri, 16 May 2014 09:09:38 -0600 From: Eric Blake MIME-Version: 1.0 References: <1400192774-606-1-git-send-email-mreitz@redhat.com> <1400192774-606-2-git-send-email-mreitz@redhat.com> <53754526.5090407@redhat.com> <5376241A.3050904@redhat.com> In-Reply-To: <5376241A.3050904@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="G3E4UD2CNbodXVVoTRXLrMGIPB9Qssvbm" Subject: Re: [Qemu-devel] [PATCH 1/7] iotests: Allow out-of-tree run List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Markus Armbruster , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --G3E4UD2CNbodXVVoTRXLrMGIPB9Qssvbm Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/16/2014 08:43 AM, Max Reitz wrote: >>> + source_iotests=3D"$(cd "$(dirname "$(readlink "$0")")"; pwd)" >> This is potentially dangerous. If readlink or dirname fails, you can >> invoke cd "" (which on bash is stupidly a no-op instead of an error), >> and end up calling pwd in the wrong directory. But in the common case= >> it works, so I'm not sure it's worth bending over backwards to make it= >> more robust. >=20 > I guess using something like >=20 > source_iotests=3D"$(dirname "$(readlink "$0")")"; if [ -z "$source_iote= sts" ]; then; /* abort */; fi; > source_iotests=3D"$(cd "$dirname"; pwd)" >=20 > should work better, then? Or even safer with source_iotests=3D$(cd "$dirname" && pwd) || /* abort */ in the second step, to ensure both the cd and pwd commands succeeded. (By the way, assignment context does not require "" when passing a single shell word, such as command substitution, so foo=3D$(...) and foo=3D"$(...)" are identical) >=20 >> Is [ ! '(' -o ')' ] true or false? Depends on whether it was parsed as= { >> ! '(' } -o ')' (false -o true =3D> true) or as ! { '(' -o ')' } (! (tr= ue >> -o true) =3D> false) >> >> But this is bash, so you could do: >> >> if [[ $arch && -x $build_root/$arch-softmmu/qemu-system-$arch ]] >> >> for less typing, and no risk of [] ambiguity. >=20 > If you're telling me I'm free to use bashisms, I'll believe you. :-) Well, the script IS being run by /bin/bash, and you already ARE using bashisms elsewhere. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --G3E4UD2CNbodXVVoTRXLrMGIPB9Qssvbm 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/ iQEcBAEBCAAGBQJTdioyAAoJEKeha0olJ0NqUgAH+gMF+5z6IROgiZY3AJ3NGFq6 PbDbfXryV61CuoFyhh7oBStcp9rT6Zo6zMhyXdP4jMbGHh93VeW3H9b+nhirPFkh +czMX18T8ybLuhIWUIPmhQNKXwyw0NNqybMEuoQakn7RyrVqGSIyEfiqUMjNX0w5 4rM0qc+1x9of9x20/BVgPZShnlZfTikRoGFOnxKH9XU7QKwzOVAN+KkHv5TX4iFa ilyn1cyKliocnOHRL0/+qTS3It5CBHdxcTLXKpy3xkRNsSw9C9ypf4x5YY9sZhAT HOD/yhoXCn8fmM1LlVdqQMt0yqS0AonKpT7xmxIMgwV6P0dvpm8XOsA2eF1Y83U= =T3lv -----END PGP SIGNATURE----- --G3E4UD2CNbodXVVoTRXLrMGIPB9Qssvbm--