aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-10-31 21:52:24 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-10-31 21:52:24 +1300
commita469c1ef50d0c03b93add44e50afa5d791855106 (patch)
tree1c849ff1bde6a28add6efe43afb44735c367ce9b
parentRevert "Drastically simplify `lint` scripts" (diff)
downloaddotfiles-a469c1ef50d0c03b93add44e50afa5d791855106.tar.gz
dotfiles-a469c1ef50d0c03b93add44e50afa5d791855106.zip
Adjust `check-bin`, `lint-bin` for built scripts
Make the `$(BINS)` target a prerequisite of `check-bin` so that all of the scripts with a #!/bin/sh shebang are built, and then check them all by iterating through a glob (and hence an order according to LC_COLLATE) and stripping the `.sh` suffix to find the name of the matching shebanged script. Leverage `shellcheck`'s support of multiple check arguments to build an argument list of the binscripts first before passing all of those to a single call, simply for speed. We don't have anything in this target to test the scripts of any other type, such as the `.awk` or `.sed` scripts. `gawk` has a `--lint` mode that might apply.
-rw-r--r--Makefile2
-rw-r--r--check/bin.sh2
-rw-r--r--lint/bin.sh6
3 files changed, 7 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 314c2a2b..0b734595 100644
--- a/Makefile
+++ b/Makefile
@@ -538,7 +538,7 @@ check: check-bin \
check-bash:
sh check/bash.sh
-check-bin: $(BINS_SH)
+check-bin: $(BINS)
sh check/bin.sh
check-games:
diff --git a/check/bin.sh b/check/bin.sh
index 04b0da6b..87bea709 100644
--- a/check/bin.sh
+++ b/check/bin.sh
@@ -1,4 +1,4 @@
for bin in bin/*.sh ; do
- sh -n "$bin" || exit
+ sh -n -- "${bin%.sh}" || exit
done
printf 'All shell scripts in bin parsed successfully.\n'
diff --git a/lint/bin.sh b/lint/bin.sh
index 0fe82d7a..16facb6a 100644
--- a/lint/bin.sh
+++ b/lint/bin.sh
@@ -1 +1,5 @@
-find bin -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s sh -- {} +
+set --
+for sh in bin/*.sh ; do
+ set "$@" "${sh%.sh}"
+done
+shellcheck -e SC1090 -- "$@"