From 84999ca51023c2b1a746051f524af3219246b718 Mon Sep 17 00:00:00 2001 From: "Troy J. Farrell" Date: Mon, 6 Feb 2017 11:41:21 -0600 Subject: [PATCH] Exit immediately on non-zero status from pipelines Prior to this change, the script allowed for silent failures of pipelines. This change uses the set -e command to alter that default behavior. This change also ignores a non-zero status when unmount is called to unmount the USB device's first partition. Testing showed that the umount command returned a non-zero status on every execution because the partition was not mounted. Prior to this change, the same non-zero status was being ignored. Related: https://github.com/calmh/smartos-platform-upgrade/issues/14 --- platform-upgrade | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform-upgrade b/platform-upgrade index dd6074c..181146c 100755 --- a/platform-upgrade +++ b/platform-upgrade @@ -3,6 +3,7 @@ # https://github.com/calmh/smartos-platform-upgrade # Copyright (c) 2012-2016 Jakob Borg & Contributors # Distributed under the MIT License +set -e # us-east.manta.joyent.com currently uses a wildcard certificate based on the # Thawte Primary Root CA. @@ -127,7 +128,8 @@ else echo -n " using $usb" fi -umount "$usb" 2>/dev/null +# This command may fail if the USB partition is not mounted. +umount "$usb" 2>/dev/null || true mkdir usb if ! mount -F pcfs -o foldcase "$usb" "$tmp/usb" ; then echo ", mount failed"