From 9f6f02f22ea52d4350156eca925e34b945dfafcd Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Fri, 4 Sep 2020 15:51:36 -0700 Subject: [PATCH] scripts: Detect shellcheck errors by looking at the length of shellcheck.log shellcheck does not seem to reliably return error codes, at least on the 0.7.0 version packaged on Fedora. Instead, look at whether shellcheck.log contains any output. Change-Id: Iec3c4f416844eed6a6c75b9204e24c2bc7243f7a Signed-off-by: Ben Walker Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4072 Tested-by: SPDK CI Jenkins Reviewed-by: Michal Berger Reviewed-by: Paul Luse Reviewed-by: Shuhei Matsumoto Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris --- scripts/check_format.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/check_format.sh b/scripts/check_format.sh index 73c4ff67f..5f10d4d1e 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -428,9 +428,8 @@ SC2119,SC2120,SC2148,SC2153,SC2154,SC2164,SC2174,SC2001,SC2206,SC2207,SC2223" SHCK_APPLY=false SHCH_ARGS=" -x -e $SHCK_EXCLUDE -f $SHCK_FORMAT" - error=0 - git ls-files '*.sh' | xargs -P$(nproc) -n1 shellcheck $SHCH_ARGS &> shellcheck.log || error=1 - if [ $error -ne 0 ]; then + git ls-files '*.sh' | xargs -P$(nproc) -n1 shellcheck $SHCH_ARGS &> shellcheck.log + if [[ -s shellcheck.log ]]; then echo " Bash formatting errors detected!" cat shellcheck.log