Skip to content

Commit

Permalink
Update shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
paradigm committed May 12, 2021
1 parent 460bd10 commit ddcd141
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/slash-bedrock/libexec/brl-repair
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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}"
Expand All @@ -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}"
Expand Down

0 comments on commit ddcd141

Please sign in to comment.