From 5d116c86aea19670147a7f0c0c95a18b5444a3a2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 22:12:16 +1300 Subject: Apply stable check and lint methods to games shell This applies the same stable approach to testing the actual built games that are shebannged with #!/bin/sh as has been applied to the shell scripts in the `check-bin` and `lint-bin` targets. There are no GNU Bash games in these directories, so the latter block of code from the `bin` analogues to check or lint those is not needed. The same applies here; this is not as complete a checking or linting of the games directory as it could be; ideally we would check the sed(1) and awk(1) scripts too. --- Makefile | 2 +- check/games.sh | 5 +++-- lint/games.sh | 8 +++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 0b734595..84da1d44 100644 --- a/Makefile +++ b/Makefile @@ -541,7 +541,7 @@ check-bash: check-bin: $(BINS) sh check/bin.sh -check-games: +check-games: $(GAMES) sh check/games.sh check-man: diff --git a/check/games.sh b/check/games.sh index 79d53ed5..7d1c3694 100644 --- a/check/games.sh +++ b/check/games.sh @@ -1,4 +1,5 @@ +# POSIX sh for game in games/*.sh ; do - sh -n "$game" || exit + sh -n -- "${game%.sh}" || exit done -printf 'All shell scripts in games parsed successfully.\n' +printf 'sh(1) games parsed successfully.\n' diff --git a/lint/games.sh b/lint/games.sh index 6e3e3024..fa2c7a97 100644 --- a/lint/games.sh +++ b/lint/games.sh @@ -1 +1,7 @@ -find games -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s sh -- {} + +# POSIX sh +set -- +for game in games/*.sh ; do + set "$@" "${game%.sh}" +done +shellcheck -e SC1090 -- "$@" || exit +printf 'sh(1) games linted successfully.\n' -- cgit v1.2.3