From 1a3e41f2813d871970b5197ed4ce63b7f18df28a Mon Sep 17 00:00:00 2001 From: Karol Latecki Date: Mon, 5 Aug 2019 15:40:06 +0200 Subject: [PATCH] scripts/check_format.sh: shellcheck fallback to tty Fall back to tty output in case diff cannot be used for not auto-fixable errors. Change-Id: I481ad0dbe8e42cf510fa3a02636bc0117630da14 Signed-off-by: Karol Latecki Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/464171 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- scripts/check_format.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/check_format.sh b/scripts/check_format.sh index caf1a5761..ee2ea19c5 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -258,9 +258,18 @@ SC2199,SC2206,SC2207,SC2209,SC2214,SC2219,SC2220,SC2223,SC2230,SC2231,SC2235" SHCH_ARGS=" -e $SHCK_EXCLUDE -f $SHCK_FORMAT" error=0 - git ls-files '*.sh' | xargs -P$(nproc) -n1 shellcheck $SHCH_ARGS > shellcheck.log || error=1 + git ls-files '*.sh' | xargs -P$(nproc) -n1 shellcheck $SHCH_ARGS &> shellcheck.log || error=1 if [ $error -ne 0 ]; then echo " Bash formatting errors detected!" + + # Some errors are not auto-fixable. Fall back to tty output. + if grep -q "Use another format to see them." shellcheck.log; then + SHCK_FORMAT="tty" + SHCK_APPLY=false + SHCH_ARGS=" -e $SHCK_EXCLUDE -f $SHCK_FORMAT" + git ls-files '*.sh' | xargs -P$(nproc) -n1 shellcheck $SHCH_ARGS > shellcheck.log || error=1 + fi + cat shellcheck.log if $SHCK_APPLY; then git apply shellcheck.log