From ddcd141394a39d86886f9c342a85b3bf16d3d692 Mon Sep 17 00:00:00 2001 From: Daniel Thau Date: Tue, 11 May 2021 08:05:44 -0400 Subject: [PATCH] Update shellcheck --- Makefile | 10 ++++++---- src/slash-bedrock/libexec/brl-repair | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index b1ede453..b987ff2e 100644 --- a/Makefile +++ b/Makefile @@ -960,22 +960,24 @@ check: # - SC2059: don't use variables in printf format string. Following # this recommendation with ANSI color variables did not work for some # reason. Excluding the check for the time being. - # - SC2039: `[ \< ]` and `[ \> ]` are non-POSIX. However, they do work + # - SC2039, SC3012: `[ \< ]` and `[ \> ]` are non-POSIX. However, they do work # with busybox. + # - SC3045, SC3040: busybox-ism is okay # - SC1090: Can't follow dynamic sources. That's fine, we know where # they are and are including them in the list to be checked. + export EXCLUDE="SC1008,SC2059,SC2039,SC1090,SC3012,SC3045,SC3040"; \ for file in $$(find src/ -type f); do \ if head -n1 "$$file" | grep -q '^#!.*busybox sh$$'; then \ echo "checking shell file $$file"; \ - shellcheck -x -s sh --exclude="SC1008,SC2059,SC2039,SC1090" "$$file" || exit 1; \ + shellcheck -x -s sh --exclude="$${EXCLUDE}" "$$file" || exit 1; \ ! cat "$$file" | shfmt -p -d | grep '.' || exit 1; \ elif head -n1 "$$file" | grep -q '^#!.*bash$$'; then \ echo "checking bash file $$file"; \ - shellcheck -x -s bash --exclude="SC1008,SC2059,SC2039,SC1090" "$$file" || exit 1; \ + shellcheck -x -s bash --exclude="$${EXCLUDE}" "$$file" || exit 1; \ ! cat "$$file" | shfmt -ln bash -d | grep '.' || exit 1; \ elif head -n1 "$$file" | grep -q -e '^#!.*zsh$$' -e '^#compdef' "$$file"; then \ echo "checking zsh file $$file"; \ - shellcheck -x -s bash --exclude="SC1008,SC2059,SC2039,SC1090" "$$file" || exit 1; \ + shellcheck -x -s bash --exclude="$${EXCLUDE}" "$$file" || exit 1; \ ! cat "$$file" | shfmt -ln bash -d | grep '.' || exit 1; \ fi; \ done diff --git a/src/slash-bedrock/libexec/brl-repair b/src/slash-bedrock/libexec/brl-repair index 8fc72020..a01d16dd 100755 --- a/src/slash-bedrock/libexec/brl-repair +++ b/src/slash-bedrock/libexec/brl-repair @@ -62,7 +62,7 @@ ensure_mnt() { # If a non-global mount exists, unmount it. if [ "${type}" != "missing" ] && ! "${global}"; then - if [ "${strategy}" == "new" ]; then + if [ "${strategy}" = "new" ]; then abort "Cannot repair \"$stratum\" with --new strategy due to problematic mount at \"${mnt}\"" fi umount_r --init "${root}${mnt}" @@ -72,7 +72,7 @@ ensure_mnt() { # If a mount exists but it is the incorrect filesystem type, unmount it. if [ "${type}" != "missing" ] && [ -n "$tgt_type" ] && [ "${type}" != "${tgt_type}" ]; then - if [ "${strategy}" == "new" ]; then + if [ "${strategy}" = "new" ]; then abort "Cannot repair \"$stratum\" with --new strategy due to problematic mount at \"${mnt}\"" fi umount_r --init "${root}${mnt}" @@ -83,7 +83,7 @@ ensure_mnt() { # If a mount point is private but needs to be shared, we need to # re-mount it with shared set on the source. if ! is_bedrock "${stratum}" && ! "${shared}" && "${tgt_share}"; then - if [ "${strategy}" == "new" ]; then + if [ "${strategy}" = "new" ]; then abort "Cannot repair \"$stratum\" with --new strategy due to problematic mount at \"${mnt}\"" fi umount_r --init "${root}${mnt}"