From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlJnv-0006UE-5s for qemu-devel@nongnu.org; Fri, 16 May 2014 11:12:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WlJnm-0007id-AM for qemu-devel@nongnu.org; Fri, 16 May 2014 11:12:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55179) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlJnm-0007iX-24 for qemu-devel@nongnu.org; Fri, 16 May 2014 11:12:02 -0400 Message-ID: <53762ABC.30002@redhat.com> Date: Fri, 16 May 2014 17:11:56 +0200 From: Max Reitz 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> <53762A32.1070407@redhat.com> In-Reply-To: <53762A32.1070407@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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: Eric Blake , qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Markus Armbruster , Stefan Hajnoczi On 16.05.2014 17:09, Eric Blake wrote: > On 05/16/2014 08:43 AM, Max Reitz wrote: > >>>> + source_iotests="$(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. >> I guess using something like >> >> source_iotests="$(dirname "$(readlink "$0")")"; if [ -z "$source_iotests" ]; then; /* abort */; fi; >> source_iotests="$(cd "$dirname"; pwd)" >> >> should work better, then? > Or even safer with > > source_iotests=$(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=$(...) and > foo="$(...)" are identical) The more you know... (and of course I meant "$source_iotests" in the second step) >>> Is [ ! '(' -o ')' ] true or false? Depends on whether it was parsed as { >>> ! '(' } -o ')' (false -o true => true) or as ! { '(' -o ')' } (! (true >>> -o true) => 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. >> 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. I feared so. *g* Max