diff --git a/terraform_tflint.sh b/terraform_tflint.sh index 6da3b93ac..0473a4a5f 100755 --- a/terraform_tflint.sh +++ b/terraform_tflint.sh @@ -61,19 +61,12 @@ tflint_() { for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do path_uniq="${path_uniq//__REPLACED__SPACE__/ }" - pushd "$path_uniq" > /dev/null - TFLINT_MSG=$( - tflint "${ARGS[@]}" 2>&1 || - echo >&2 -e "\033[1;31m\nERROR in ./$path_uniq/:\033[0m" && - tflint "${ARGS[@]}" # Print TFLint error with PATH - ) - # Print checked PATH if TFLint have any messages - if [ ! -z "$TFLINT_MSG" ]; then - echo -e "\n./$path_uniq/:" - echo "$TFLINT_MSG" - fi + # Print checked PATH **only** if TFLint have any messages + # shellcheck disable=SC2091 # Suppress error output + $(tflint "${ARGS[@]}" 2>&1) || + echo >&2 -e "\033[1;31m\nERROR in $path_uniq/:\033[0m" && tflint "${ARGS[@]}" popd > /dev/null done