public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Henning Schild <henning.schild@siemens.com>
To: isar-users@googlegroups.com
Cc: Henning Schild <henning.schild@siemens.com>
Subject: [PATCH 3/3] scripts/start_vm: Deduplicate start_qemu
Date: Thu, 12 Apr 2018 16:48:57 +0200	[thread overview]
Message-ID: <b87a40f8ba8adeda443b79bd2dfc05c4b39fb00c.1523544076.git.henning.schild@siemens.com> (raw)
In-Reply-To: <7219cddfebd75ac1527471df0118009e6c9ae530.1523544076.git.henning.schild@siemens.com>
In-Reply-To: <7219cddfebd75ac1527471df0118009e6c9ae530.1523544076.git.henning.schild@siemens.com>

Instead of echoing what we are about to execute, switch the shell to
verbose mode. But only toggle "x" if it was not seet already.

This simplifies the script and future changes will only have to touch
one spot.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 scripts/start_vm | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/scripts/start_vm b/scripts/start_vm
index 4cb05ae..26274be 100755
--- a/scripts/start_vm
+++ b/scripts/start_vm
@@ -17,22 +17,11 @@ bb2sh() {
 }
 
 start_qemu() {
-    root1=`echo $QEMU_ROOTFS_DEV \
-        | sed 's,##ROOTFS_IMAGE##,$IMAGE_DIR/'"$ROOTFS_IMAGE"','`
-    echo -e "IMAGE_DIR=$IMAGE_DIR; \\\\\n\
-qemu-system-$QEMU_ARCH \\\\\n\
-    -m 1024M \\\\\n\
-    -M $QEMU_MACHINE \\\\\n\
-    $QCPU\\\\\n\
-    -nographic \\\\\n\
-    -kernel \$QKERNEL \\\\\n\
-    -initrd \$QINITRD \\\\\n\
-    -append \"console=$MACHINE_SERIAL root=/dev/$ROOTFS_DEV rw\" \\\\\n\
-    $EXTRA_ARGS \\\\\n\
-    $root1"
-
-    root2=`echo $QEMU_ROOTFS_DEV \
+    root=`echo $QEMU_ROOTFS_DEV \
         | sed 's,##ROOTFS_IMAGE##,'$IMAGE_DIR/$ROOTFS_IMAGE','`
+    local had_x
+    echo $- | grep -q x && had_x=1 || had_x=0
+    [ $had_x -eq 0 ] && set -x
     qemu-system-$QEMU_ARCH \
 	-m 1024M \
 	-M $QEMU_MACHINE \
@@ -42,7 +31,8 @@ qemu-system-$QEMU_ARCH \\\\\n\
 	-initrd $QINITRD \
 	-append "console=$MACHINE_SERIAL root=/dev/$ROOTFS_DEV rw" \
 	$EXTRA_ARGS \
-	$root2
+	$root
+    [ $had_x -eq 0 ] && set +x
 }
 
 show_help() {
-- 
2.16.1


  parent reply	other threads:[~2018-04-12 14:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-12 14:48 [PATCH 1/3] scripts: Make building verbose for better failure analysis Henning Schild
2018-04-12 14:48 ` [PATCH 2/3] scripts/isar-buildenv-internal: Remove unused variable Henning Schild
2018-04-23  6:03   ` Baurzhan Ismagulov
2018-04-12 14:48 ` Henning Schild [this message]
2018-04-23  6:06   ` [PATCH 3/3] scripts/start_vm: Deduplicate start_qemu Baurzhan Ismagulov
2018-04-23  6:03 ` [PATCH 1/3] scripts: Make building verbose for better failure analysis Baurzhan Ismagulov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b87a40f8ba8adeda443b79bd2dfc05c4b39fb00c.1523544076.git.henning.schild@siemens.com \
    --to=henning.schild@siemens.com \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox