From 196155499c04b2c2050302e6575f1bcbbed052f1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 20:28:49 +1300 Subject: Drastically simplify `lint` scripts Using find(1) to run the appropriate lint program over a set of files allows us to be terse and deal a little more dynamically with new files placed in the directories, but the downsides are that it's error-prone and that the order of testing is not predictable, and we'd ideally like the testing to be a little more deterministic than that. Case in point: writing the code for this commit unintentionally uncovered a longstanding issue where the URxvt Perl script `select.pl` was actually not being checked at all, due to an unneeded exclamation mark inverting the `-name` test for `*.pl` files. `select.pl` is presently not passing `perlcritic --brutal` on my machine, and likely has not been compliant since as early as commit 5000365 in March this year: >commit 500036564541ff2d65a7b2f6f6f556202d72d6ce >Author: Tom Ryder >Date: Fri Mar 24 11:01:05 2017 > > Lots of Makefile tidying > > ... > * Favour find(1) calls over shell loops > ... This commit also more clearly delineates between the language being "linted" and the target for which it's being linted. The latter is likely more desirable. This needs clarification. --- lint/games.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lint/games.sh') diff --git a/lint/games.sh b/lint/games.sh index 6e3e3024..772c8678 100644 --- a/lint/games.sh +++ b/lint/games.sh @@ -1 +1,2 @@ -find games -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s sh -- {} + +shellcheck -e SC1090 -s sh -- \ + games/*.sh -- cgit v1.2.3 From 111c8d9db7798ccccd07157f346f2c039131cfc9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 20:46:10 +1300 Subject: Revert "Drastically simplify `lint` scripts" I forgot that the `lint` tools here need to check the *built* files, and that that's the reason the `perlcritic` check against the source .pl file was failing. While it's still true that it would be preferable to test the files found in a deterministic order, this branch's attempt to address that issue is pretty much nonsense and can be abandoned. This reverts commit 196155499c04b2c2050302e6575f1bcbbed052f1. --- lint/games.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lint/games.sh') diff --git a/lint/games.sh b/lint/games.sh index 772c8678..6e3e3024 100644 --- a/lint/games.sh +++ b/lint/games.sh @@ -1,2 +1 @@ -shellcheck -e SC1090 -s sh -- \ - games/*.sh +find games -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s sh -- {} + -- cgit v1.2.3 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. --- lint/games.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lint/games.sh') 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 From a179e2b48b0c6f6f57421d0f99b49ab6f4970dd5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 22:41:21 +1300 Subject: Add option terminators to some stray `set` calls Adding the option terminator "--" directly after the `set` call ensures that all following arguments will be interpreted as new arguments for the list. This is probably not strictly applicable here, because the paths that will be stacked up don't start with dashes by definition, but it's likely good practice. --- lint/games.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lint/games.sh') diff --git a/lint/games.sh b/lint/games.sh index fa2c7a97..240961af 100644 --- a/lint/games.sh +++ b/lint/games.sh @@ -1,7 +1,7 @@ # POSIX sh set -- for game in games/*.sh ; do - set "$@" "${game%.sh}" + set -- "$@" "${game%.sh}" done shellcheck -e SC1090 -- "$@" || exit printf 'sh(1) games linted successfully.\n' -- cgit v1.2.3 From 87369f1ec9913f48c5902d8e730750b8a9772eba Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 23:03:47 +1300 Subject: Correct some vestigial programs to shell names Just for consistency. --- lint/games.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lint/games.sh') diff --git a/lint/games.sh b/lint/games.sh index 240961af..6d51ba0d 100644 --- a/lint/games.sh +++ b/lint/games.sh @@ -4,4 +4,4 @@ for game in games/*.sh ; do set -- "$@" "${game%.sh}" done shellcheck -e SC1090 -- "$@" || exit -printf 'sh(1) games linted successfully.\n' +printf 'POSIX shell games linted successfully.\n' -- cgit v1.2.3