From 93029dcfcf6b9b121c24573f3e647d9fde255486 Mon Sep 17 00:00:00 2001 From: Maxime Brunet Date: Sat, 18 Dec 2021 10:07:36 -0800 Subject: [PATCH] fix(terraform_tflint): Restore current working directory behavior (#302) --- terraform_tflint.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/terraform_tflint.sh b/terraform_tflint.sh index 66cf1fc68..87c120383 100755 --- a/terraform_tflint.sh +++ b/terraform_tflint.sh @@ -62,17 +62,20 @@ tflint_() { tflint_final_exit_code=0 for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do path_uniq="${path_uniq//__REPLACED__SPACE__/ }" + pushd "$path_uniq" > /dev/null # Print checked PATH **only** if TFLint have any messages # shellcheck disable=SC2091 # Suppress error output - $(tflint "${ARGS[@]}" $path_uniq 2>&1) 2> /dev/null || { + $(tflint "${ARGS[@]}" 2>&1) 2> /dev/null || { echo >&2 -e "\033[1;33m\nTFLint in $path_uniq/:\033[0m" - tflint "${ARGS[@]}" $path_uniq + tflint "${ARGS[@]}" } local exit_code=$? if [ $exit_code != 0 ]; then tflint_final_exit_code=$exit_code fi + + popd > /dev/null done set -e exit $tflint_final_exit_code