Hi Max:

On 11/19/2015 12:45 AM, Max Reitz wrote:
On 04.11.2015 03:26, Bo Tu wrote:
Replacing sed with awk, then it's easier to read.

I think you meant "awk with sed".

It's my fault. thanks :-)


Replacing "[ ! -z "$default_alias_machine" ]" with
"[[ $default_alias_machine ]]", then it's slightly shorter.

Suggested-By: Sascha Silbe <si...@linux.vnet.ibm.com>
Reviewed-by: Sascha Silbe <si...@linux.vnet.ibm.com>
Reviewed-by: Eric Blake   <ebl...@redhat.com>
Signed-off-by: Bo Tu <t...@linux.vnet.ibm.com>
---
  tests/qemu-iotests/common.config | 9 ++++-----
  1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
index 596bb2b..08f4b4e 100644
--- a/tests/qemu-iotests/common.config
+++ b/tests/qemu-iotests/common.config
@@ -128,11 +128,10 @@ export QEMU_IMG=_qemu_img_wrapper
  export QEMU_IO=_qemu_io_wrapper
  export QEMU_NBD=_qemu_nbd_wrapper

-default_machine=$($QEMU -machine \? | awk '/(default)/{print $1}')
-default_alias_machine=$($QEMU -machine \? |\
-    awk -v var_default_machine="$default_machine"\)\
-    '{if ($(NF-2)=="(alias"&&$(NF-1)=="of"&&$(NF)==var_default_machine){print 
$1}}')
-if [ ! -z "$default_alias_machine" ]; then
+default_machine=$($QEMU -machine help | sed -n '/(default)/ s/ .*//p')
+default_alias_machine=$($QEMU -machine help | \
+   sed -n "/(alias of $default_machine)"/' { s/ .*//p; q; }')

Could be shortened to "/(alias of $default_machine)/ { s/ .*//p; q; }"
(superfluous quotation marks), but that doesn't make it less correct.

Yes. it can reduce two quotation marks. Good suggestion.



With the commit message fixed:

Reviewed-by: Max Reitz <mre...@redhat.com>

I'll add it in the patch of v3.


+if [[ "$default_alias_machine" ]]; then
      default_machine="$default_alias_machine"
  fi






Reply via email to