From 6a96222b430214bb9a878b3bc96311d858211b52 Mon Sep 17 00:00:00 2001 From: Epic Curious <109078515+epiccurious@users.noreply.github.com> Date: Mon, 18 Dec 2023 10:52:59 -0500 Subject: [PATCH] feat: add nounset and pipefail bash options (#66) * feat: add nounset and pipefail options * fix: unbound variable --- device_specific/flash_the_m5stack_core_basic | 6 ++++-- device_specific/flash_the_m5stack_fire | 6 ++++-- device_specific/flash_the_m5stack_m5stickc_plus | 6 ++++-- device_specific/flash_the_ttgo_tdisplay | 6 ++++-- flash_your_device | 6 ++++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/device_specific/flash_the_m5stack_core_basic b/device_specific/flash_the_m5stack_core_basic index 17ca126..03d5c2f 100755 --- a/device_specific/flash_the_m5stack_core_basic +++ b/device_specific/flash_the_m5stack_core_basic @@ -1,9 +1,11 @@ #!/bin/bash -set -e +set -o errexit +set -o nounset +set -o pipefail cleanup() { rm -rf -- "${temp_directory}" - if [ -n "${initial_tty_device_permissions}" ] && + if [ -n "${initial_tty_device_permissions:-}" ] && [ "$(stat -c '%a' "${tty_device}")" != "${initial_tty_device_permissions}" ]; then sudo chmod "${initial_tty_device_permissions}" "${tty_device}" fi diff --git a/device_specific/flash_the_m5stack_fire b/device_specific/flash_the_m5stack_fire index f640271..82f6507 100755 --- a/device_specific/flash_the_m5stack_fire +++ b/device_specific/flash_the_m5stack_fire @@ -1,9 +1,11 @@ #!/bin/bash -set -e +set -o errexit +set -o nounset +set -o pipefail cleanup() { rm -rf -- "${temp_directory}" - if [ -n "${initial_tty_device_permissions}" ] && + if [ -n "${initial_tty_device_permissions:-}" ] && [ "$(stat -c '%a' "${tty_device}")" != "${initial_tty_device_permissions}" ]; then sudo chmod "${initial_tty_device_permissions}" "${tty_device}" fi diff --git a/device_specific/flash_the_m5stack_m5stickc_plus b/device_specific/flash_the_m5stack_m5stickc_plus index 2b74d3c..dd71052 100755 --- a/device_specific/flash_the_m5stack_m5stickc_plus +++ b/device_specific/flash_the_m5stack_m5stickc_plus @@ -1,9 +1,11 @@ #!/bin/bash -set -e +set -o errexit +set -o nounset +set -o pipefail cleanup() { rm -rf -- "${temp_directory}" - if [ -n "${initial_tty_device_permissions}" ] && + if [ -n "${initial_tty_device_permissions:-}" ] && [ "$(stat -c '%a' "${tty_device}")" != "${initial_tty_device_permissions}" ]; then sudo chmod "${initial_tty_device_permissions}" "${tty_device}" fi diff --git a/device_specific/flash_the_ttgo_tdisplay b/device_specific/flash_the_ttgo_tdisplay index 6b822a3..24af78b 100755 --- a/device_specific/flash_the_ttgo_tdisplay +++ b/device_specific/flash_the_ttgo_tdisplay @@ -1,9 +1,11 @@ #!/bin/bash -set -e +set -o errexit +set -o nounset +set -o pipefail cleanup() { rm -rf -- "${temp_directory}" - if [ -n "${initial_tty_device_permissions}" ] && + if [ -n "${initial_tty_device_permissions:-}" ] && [ "$(stat -c '%a' "${tty_device}")" != "${initial_tty_device_permissions}" ]; then sudo chmod "${initial_tty_device_permissions}" "${tty_device}" fi diff --git a/flash_your_device b/flash_your_device index 3075440..2340cc0 100755 --- a/flash_your_device +++ b/flash_your_device @@ -1,10 +1,12 @@ #!/bin/bash -set -e +set -o errexit +set -o nounset +set -o pipefail cleanup() { rm -rf -- "${temp_directory}" if [ "${machine}" == "Linux" ] && - [ -n "${initial_tty_device_permissions}" ] && + [ -n "${initial_tty_device_permissions:-}" ] && [ "$(stat -c '%a' "${tty_device}")" != "${initial_tty_device_permissions}" ]; then sudo chmod "${initial_tty_device_permissions}" "${tty_device}" fi