From 919bf0c5b89355665a6a42c88ff6f1cd54ac4370 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 22 Aug 2012 15:32:39 -0400 Subject: [PATCH] image_to_vm.sh: avoid subshells There is a bug in bash where BASH_COMMAND is not correct when an error is hit in a subshell (it retains the command run *before* the subshell). Since this has confused a few people using image_to_vm.sh so far, drop the use of subshells in this file. They weren't necessary in the first place so it isn't like we're losing anything. URL: http://lists.gnu.org/archive/html/bug-bash/2012-08/msg00052.html BUG=None TEST=`./image_to_vm.sh --board=x86-alex --from=../build/images/x86-alex/latest` still works TEST=`rm ../build/images/x86-alex/latest/chromiumos_image.bin && ./image_to_vm.sh --board=x86-alex --from=../build/images/x86-alex/latest/` reports correct line Change-Id: Iaa7560b4868128119a4f6223b54020611f203635 Reviewed-on: https://gerrit.chromium.org/gerrit/31135 Reviewed-by: Brian Harring Commit-Ready: Mike Frysinger Tested-by: Mike Frysinger --- image_to_vm.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/image_to_vm.sh b/image_to_vm.sh index 5fc512ea99..258c1195d2 100755 --- a/image_to_vm.sh +++ b/image_to_vm.sh @@ -69,8 +69,8 @@ if [ -z "${FLAGS_board}" ] ; then fi if [ "${FLAGS_full}" -eq "${FLAGS_TRUE}" ] && \ - ( [[ ${FLAGS_vdisk_size} < ${MIN_VDISK_SIZE_FULL} ]] || \ - [[ ${FLAGS_statefulfs_size} < ${MIN_STATEFUL_FS_SIZE_FULL} ]]); then + [[ ${FLAGS_vdisk_size} < ${MIN_VDISK_SIZE_FULL} || \ + ${FLAGS_statefulfs_size} < ${MIN_STATEFUL_FS_SIZE_FULL} ]]; then warn "Disk is too small for full, using minimum: vdisk size equal to \ ${MIN_VDISK_SIZE_FULL} and statefulfs size equal to \ ${MIN_STATEFUL_FS_SIZE_FULL}." @@ -113,8 +113,9 @@ FLAGS_to=`eval readlink -f $FLAGS_to` # Split apart the partitions and make some new ones TEMP_DIR=$(mktemp -d) -(cd "${TEMP_DIR}" && - "${FLAGS_from}/unpack_partitions.sh" "${SRC_IMAGE}") +pushd "${TEMP_DIR}" >/dev/null +"${FLAGS_from}/unpack_partitions.sh" "${SRC_IMAGE}" +popd >/dev/null # Fix the kernel command line TEMP_ESP="${TEMP_DIR}"/part_12