[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/7] iotests: Allow out-of-tree run
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH 1/7] iotests: Allow out-of-tree run |
Date: |
Fri, 16 May 2014 09:09:38 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
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)
>
>> 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.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
[Qemu-devel] [PATCH 2/7] configure: Enable out-of-tree iotests, Max Reitz, 2014/05/15
[Qemu-devel] [PATCH 4/7] iotests: Source common.env, Max Reitz, 2014/05/15
[Qemu-devel] [PATCH 5/7] iotests: Use $PYTHON for Python scripts, Max Reitz, 2014/05/15
[Qemu-devel] [PATCH 3/7] iotests: Add default common.env, Max Reitz, 2014/05/15
[Qemu-devel] [PATCH 6/7] iotests: Drop Python version from 065's Shebang, Max Reitz, 2014/05/15