From fba5b36a680330aec1fb89f2e294ffd2962bdf07 Mon Sep 17 00:00:00 2001 From: img2tab <31696646+img2tab@users.noreply.github.com> Date: Sat, 29 Jun 2019 05:06:10 +0300 Subject: [PATCH] moved "exception handling" to the top of the loop --- macos-guest-virtualbox.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/macos-guest-virtualbox.sh b/macos-guest-virtualbox.sh index b267591..17043fd 100644 --- a/macos-guest-virtualbox.sh +++ b/macos-guest-virtualbox.sh @@ -2,7 +2,7 @@ # Semi-automatic installer of macOS on VirtualBox # (c) img2tab, licensed under GPL2.0 or higher # url: https://github.com/img2tab/macos-guest-virtualbox -# version 0.67.0 +# version 0.67.1 # Requirements: 37.5GB available storage on host # Dependencies: bash >= 4.0, unzip, wget, dmg2img, @@ -262,6 +262,11 @@ wget "${sucatalog}" \ echo "Trying to find macOS ${macOS_release_name} InstallAssistant download URL" tac "${macOS_release_name}_sucatalog" | csplit - '/InstallAssistantAuto.smd/+1' '{*}' -f "${macOS_release_name}_sucatalog_" -s for catalog in "${macOS_release_name}_sucatalog_"* "error"; do + if [[ "${catalog}" == error ]]; then + rm "${macOS_release_name}_sucatalog"* + printf "Couldn't find the requested download URL in the Apple catalog. Exiting." + exit + fi urlbase="$(tail -n 1 "${catalog}" 2>/dev/null)" urlbase="$(expr match "${urlbase}" '.*\(http://[^<]*/\)')" wget "${urlbase}InstallAssistantAuto.smd" \ @@ -273,10 +278,6 @@ for catalog in "${macOS_release_name}_sucatalog_"* "error"; do echo "" rm "${macOS_release_name}_sucatalog"* break - elif [[ "${catalog}" == error ]]; then - rm "${macOS_release_name}_sucatalog"* - printf "Couldn't find the requested download URL in the Apple catalog. Exiting." - exit fi done echo "Downloading macOS installation files from swcdn.apple.com"