From 8302fc7afd764a65d9bf149feb1e908fa5be5a9a Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Fri, 1 May 2020 12:13:44 +0100 Subject: [PATCH] Fix brace expansion of @ for bash 3.x --- bin/terraform | 6 +++--- bin/tfenv | 4 ++-- lib/bashlog.sh | 6 +++--- libexec/tfenv-exec | 6 +++--- test/run.sh | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bin/terraform b/bin/terraform index 08137ce..a2e12a9 100755 --- a/bin/terraform +++ b/bin/terraform @@ -62,8 +62,8 @@ log 'debug' "program=\"${0##*/}\""; declare tfenv_path="${TFENV_ROOT}/bin/tfenv"; -log 'debug' "Exec: \"${tfenv_path}\" exec \"${@}\""; -exec "${tfenv_path}" exec "${@}" \ - || log 'error' "Failed to exec: \"${tfenv_path}\" exec \"${@}\""; +log 'debug' "Exec: \"${tfenv_path}\" exec \"$*\""; +exec "${tfenv_path}" exec "$@" \ + || log 'error' "Failed to exec: \"${tfenv_path}\" exec \"$*\""; log 'error' 'This line should not be reachable. Something catastrophic has occurred'; diff --git a/bin/tfenv b/bin/tfenv index ccc135d..ae6334a 100755 --- a/bin/tfenv +++ b/bin/tfenv @@ -104,8 +104,8 @@ exit 1; } | abort && exit 1; fi; shift 1; - log 'debug' "Exec: \"${command_path}\" \"${@}\""; - exec "${command_path}" "${@}"; + log 'debug' "Exec: \"${command_path}\" \"$*\""; + exec "${command_path}" "$@"; ;; esac; diff --git a/lib/bashlog.sh b/lib/bashlog.sh index 52ad6db..aa8a450 100755 --- a/lib/bashlog.sh +++ b/lib/bashlog.sh @@ -8,7 +8,7 @@ function _log_exception() { BASHLOG_JSON=0; BASHLOG_SYSLOG=0; - log 'error' "Logging Exception: ${@}"; + log 'error' "Logging Exception: $*"; ); }; export -f _log_exception; @@ -39,7 +39,7 @@ function log() { shift 1; - local line="${@}"; + local line="$@"; # RFC 5424 # @@ -154,7 +154,7 @@ function log() { fi; ;; *) - log 'error' "Undefined log level trying to log: ${@}"; + log 'error' "Undefined log level trying to log: $*"; ;; esac }; diff --git a/libexec/tfenv-exec b/libexec/tfenv-exec index 4195fd2..6ebcb04 100755 --- a/libexec/tfenv-exec +++ b/libexec/tfenv-exec @@ -95,9 +95,9 @@ fi; TF_BIN_PATH="${TFENV_ROOT}/versions/${TFENV_VERSION}/terraform"; export PATH="${TF_BIN_PATH}:${PATH}"; log 'debug' "TF_BIN_PATH added to PATH: ${TF_BIN_PATH}"; -log 'debug' "Executing: ${TF_BIN_PATH} ${@}"; +log 'debug' "Executing: ${TF_BIN_PATH} $@"; -exec "${TF_BIN_PATH}" "${@}" \ - || log 'error' "Failed to execute: ${TF_BIN_PATH} ${@}"; +exec "${TF_BIN_PATH}" "$@" \ + || log 'error' "Failed to execute: ${TF_BIN_PATH} $*"; exit 0; diff --git a/test/run.sh b/test/run.sh index 3a24dd5..0e1d362 100755 --- a/test/run.sh +++ b/test/run.sh @@ -51,7 +51,7 @@ export PATH="${TFENV_ROOT}/bin:${PATH}"; errors=(); if [ "${#}" -ne 0 ]; then - targets="${@}"; + targets="$@"; else targets="$(\ls "$(dirname "${0}")" | grep 'test_')"; fi;