From fd655274f8cdd68820cc1031702391af0a87e5ce Mon Sep 17 00:00:00 2001 From: 3wc <3wc.git@doesthisthing.work> Date: Sun, 14 Mar 2021 03:24:13 +0200 Subject: [PATCH] Bomb out with Bash < 4 Ref #96 --- CHANGELOG.md | 1 + abra | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 398214c..29ae15e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Support removal of secrets and volumes when `rm`'ing apps ([#44](https://git.autonomic.zone/coop-cloud/abra/issues/44)) - Always choose the default IPv4 address with `abra server init` ([#91](https://git.autonomic.zone/coop-cloud/abra/issues/91)) - Add `--type=` filtering option to `abra ls` ([0828189](https://git.autonomic.zone/coop-cloud/abra/commit/0828189)) +- Check for bash 4+ ([#96](https://git.autonomic.zone/coop-cloud/abra/commit/0828189)) # abra 0.5.0 (2021-03-01) diff --git a/abra b/abra index 0c36f78..e501177 100755 --- a/abra +++ b/abra @@ -390,6 +390,13 @@ fi ###### Safety checks +require_bash_4() { + # we're using things like `mapfile` which require bash 4+ + if ! bash -c '[[ $BASH_VERSION > 4.0 ]]'; then + error "bash version '$BASH_VERSION' is too old, 4 or newer required" + fi +} + require_pwqgen() { if ! type pwqgen > /dev/null 2>&1; then error "pwqgen program is not installed" @@ -406,12 +413,6 @@ require_abra_dir() { mkdir -p "$ABRA_DIR" } -require_stack() { - if [ -z "$STACK_NAME" ]; then - error "no stack_name, export \$STACK_NAME=my_cool_app" - fi -} - require_app_latest() { APP="$1" APP_DIR="$ABRA_DIR/apps/$APP" @@ -1634,6 +1635,8 @@ sub_network() { ####################################### abra() { + require_bash_4 + # TODO (3wc): we either need to do this, or add 'shellcheck disable' all over # the place to handle the dynamically-defined vars declare abra___stack abra___env abra__command_ abra__args_ \