From a1635eb425cb313163eb558fc52ab47a08dd8da3 Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Mon, 23 Mar 2020 15:45:15 -0700 Subject: [PATCH 1/3] fork shellcheck --- .github/workflows/shellcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index d5fa9be4447703..54e0461c3c60b6 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -10,6 +10,6 @@ jobs: - uses: actions/checkout@v2 - name: shellcheck id: shellcheck - uses: ludeeus/actions-shellcheck@0.1.0 + uses: project-chip/actions-shellcheck@0.1.0 env: EXCLUDE_DIRS: third_party From ffa42afae708ba7340c2f4a95cd51393cf809435 Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Mon, 23 Mar 2020 20:56:39 -0700 Subject: [PATCH 2/3] use master --- .github/workflows/shellcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index 54e0461c3c60b6..a126d4e6edc20e 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -10,6 +10,6 @@ jobs: - uses: actions/checkout@v2 - name: shellcheck id: shellcheck - uses: project-chip/actions-shellcheck@0.1.0 + uses: project-chip/action-shellcheck@master env: EXCLUDE_DIRS: third_party From f0a107e1962421c068599059deda022cc8a26cbb Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Mon, 23 Mar 2020 21:27:17 -0700 Subject: [PATCH 3/3] Shellcheck-proof clang-format scripts --- integrations/clang/clang-format-check.sh | 9 +++++---- integrations/clang/clang-format.sh | 13 +++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/integrations/clang/clang-format-check.sh b/integrations/clang/clang-format-check.sh index 8cb94c7c070671..d44e15aad44f15 100755 --- a/integrations/clang/clang-format-check.sh +++ b/integrations/clang/clang-format-check.sh @@ -6,20 +6,21 @@ # replacements. # +# shellcheck disable=SC2120 die() { - echo " *** ERROR: " $* + echo " *** ERROR: $*" exit 1 } # from `man diff`: # Exit status is 0 if inputs are the same, 1 if different, 2 if trouble. -$(dirname "$0")/clang-format.sh -style=file $@ | diff -u $@ - || die +"$(dirname "$0")"/clang-format.sh -style=file "$@" | diff -u "$@" - || die "diffs exist" for arg; do true; done file=$arg -[ -n "$(tail -c1 $file)" ] && { - echo " *** ERROR: Missing EOF newline: " $file +[[ -n "$(tail -c1 "$file")" ]] && { + echo " *** ERROR: Missing EOF newline: $file" exit 1 } diff --git a/integrations/clang/clang-format.sh b/integrations/clang/clang-format.sh index b2eabebad0e3ea..473268b0b9de3a 100755 --- a/integrations/clang/clang-format.sh +++ b/integrations/clang/clang-format.sh @@ -2,14 +2,15 @@ CLANG_FORMAT_VERSION="clang-format version 9.0" +# shellcheck disable=SC2120 die() { - echo " *** ERROR: " $* + echo " *** ERROR: $*" exit 1 } -if which clang-format-6.0 > /dev/null; then +if command -v clang-format-6.0 > /dev/null; then alias clang-format=clang-format-9.0 -elif which clang-format > /dev/null; then +elif command -v clang-format > /dev/null; then case "$(clang-format --version)" in "$CLANG_FORMAT_VERSION"*) ;; @@ -21,7 +22,7 @@ else die "clang-format 9.0 required" fi -clang-format $@ || die +clang-format "$@" || die "format failed" # ensure EOF newline REPLACE=no @@ -36,8 +37,8 @@ done file=$arg -[ $REPLACE != yes ] || { - [ -n "$(tail -c1 $file)" ] && echo >> $file +[[ $REPLACE != yes ]] || { + [[ -n "$(tail -c1 "$file")" ]] && echo >> "$file" } exit 0