Skip to content

Commit 3f66432

Browse files
authored
fix: terrafrom_tflint ERROR output for files located in repo root (antonbabenko#243)
1 parent 25cddd9 commit 3f66432

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

terraform_tflint.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,12 @@ tflint_() {
6161

6262
for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
6363
path_uniq="${path_uniq//__REPLACED__SPACE__/ }"
64-
6564
pushd "$path_uniq" > /dev/null
66-
TFLINT_MSG=$(
67-
tflint "${ARGS[@]}" 2>&1 ||
68-
echo >&2 -e "\033[1;31m\nERROR in ./$path_uniq/:\033[0m" &&
69-
tflint "${ARGS[@]}" # Print TFLint error with PATH
70-
)
7165

72-
# Print checked PATH if TFLint have any messages
73-
if [ ! -z "$TFLINT_MSG" ]; then
74-
echo -e "\n./$path_uniq/:"
75-
echo "$TFLINT_MSG"
76-
fi
66+
# Print checked PATH **only** if TFLint have any messages
67+
# shellcheck disable=SC2091 # Suppress error output
68+
$(tflint "${ARGS[@]}" 2>&1) ||
69+
echo >&2 -e "\033[1;31m\nERROR in $path_uniq/:\033[0m" && tflint "${ARGS[@]}"
7770

7871
popd > /dev/null
7972
done

0 commit comments

Comments
 (0)