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/bash.sh | 8 +++++++- lint/bin.sh | 3 ++- lint/games.sh | 3 ++- lint/ksh.sh | 8 +++++--- lint/sh.sh | 12 ++++++------ lint/urxvt.sh | 3 ++- lint/vim.sh | 13 ++++++++----- lint/xinit.sh | 4 +++- 8 files changed, 35 insertions(+), 19 deletions(-) diff --git a/lint/bash.sh b/lint/bash.sh index 2fe1ba13..4830b90a 100644 --- a/lint/bash.sh +++ b/lint/bash.sh @@ -1 +1,7 @@ -find bash -type f -print -exec shellcheck -e SC1090 -s bash -- {} + +shellcheck -e SC1090 -s bash -- \ + bash/bash_completion \ + bash/bash_completion.d/*.bash \ + bash/bash_logout \ + bash/bash_profile \ + bash/bashrc \ + bash/bashrc.d/*.bash diff --git a/lint/bin.sh b/lint/bin.sh index 0fe82d7a..2c990d2a 100644 --- a/lint/bin.sh +++ b/lint/bin.sh @@ -1 +1,2 @@ -find bin -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s sh -- {} + +shellcheck -e SC1090 -s sh -- \ + bin/*.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 diff --git a/lint/ksh.sh b/lint/ksh.sh index 4cedc6f7..fd558727 100644 --- a/lint/ksh.sh +++ b/lint/ksh.sh @@ -1,3 +1,5 @@ -find ksh \ - -type f -name '*.sh' -exec shellcheck -e SC1090 -s sh -- {} + -o \ - -type f -exec shellcheck -e SC1090 -s ksh -- {} + +shellcheck -e SC1090 -s sh -- \ + ksh/shrc.d/*.sh +shellcheck -e SC1090 -s ksh -- \ + ksh/kshrc \ + ksh/kshrc.d/*.ksh diff --git a/lint/sh.sh b/lint/sh.sh index 89704c0b..4f796b09 100644 --- a/lint/sh.sh +++ b/lint/sh.sh @@ -1,6 +1,6 @@ -find sh \ - keychain/profile.d keychain/shrc.d \ - ksh/shrc.d \ - mpd/profile.d \ - plenv/profile.d plenv/shrc.d \ - -type f -print -exec shellcheck -e SC1090 -s sh -- {} + +shellcheck -e SC1090 -s sh -- \ + sh/profile \ + sh/profile.d/* \ + sh/shinit \ + sh/shrc \ + sh/shrc.d/* diff --git a/lint/urxvt.sh b/lint/urxvt.sh index 507034be..7c7b1876 100644 --- a/lint/urxvt.sh +++ b/lint/urxvt.sh @@ -1 +1,2 @@ -find urxvt/ext -type f ! -name '*.pl' -print -exec perlcritic --brutal -- {} \; +perlcritic --brutal -- \ + urxvt/ext/*.pl diff --git a/lint/vim.sh b/lint/vim.sh index 6714ac9a..8197217e 100644 --- a/lint/vim.sh +++ b/lint/vim.sh @@ -1,5 +1,8 @@ -for v in vim/* ; do - [ "$v" != vim/bundle ] || continue - printf '%s\n' "$v" - vint -s -- "$v" -done +vint -s -- \ + vim/after/ \ + vim/config/ \ + vim/ftdetect/ \ + vim/ftplugin/ \ + vim/indent/ \ + vim/gvimrc \ + vim/vimrc diff --git a/lint/xinit.sh b/lint/xinit.sh index b5ff6937..cebb59a7 100644 --- a/lint/xinit.sh +++ b/lint/xinit.sh @@ -1 +1,3 @@ -find X -type f \( -name xinitrc -o -name '*.sh' \) -print -exec shellcheck -e SC1090 -s sh -- {} + +shellcheck -e SC1090 -s sh -- \ + X/xinitrc \ + X/xinitrc.d/*.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/bash.sh | 8 +------- lint/bin.sh | 3 +-- lint/games.sh | 3 +-- lint/ksh.sh | 8 +++----- lint/sh.sh | 12 ++++++------ lint/urxvt.sh | 3 +-- lint/vim.sh | 13 +++++-------- lint/xinit.sh | 4 +--- 8 files changed, 19 insertions(+), 35 deletions(-) diff --git a/lint/bash.sh b/lint/bash.sh index 4830b90a..2fe1ba13 100644 --- a/lint/bash.sh +++ b/lint/bash.sh @@ -1,7 +1 @@ -shellcheck -e SC1090 -s bash -- \ - bash/bash_completion \ - bash/bash_completion.d/*.bash \ - bash/bash_logout \ - bash/bash_profile \ - bash/bashrc \ - bash/bashrc.d/*.bash +find bash -type f -print -exec shellcheck -e SC1090 -s bash -- {} + diff --git a/lint/bin.sh b/lint/bin.sh index 2c990d2a..0fe82d7a 100644 --- a/lint/bin.sh +++ b/lint/bin.sh @@ -1,2 +1 @@ -shellcheck -e SC1090 -s sh -- \ - bin/*.sh +find bin -type f -name '*.sh' -print -exec shellcheck -e SC1090 -s 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 -- {} + diff --git a/lint/ksh.sh b/lint/ksh.sh index fd558727..4cedc6f7 100644 --- a/lint/ksh.sh +++ b/lint/ksh.sh @@ -1,5 +1,3 @@ -shellcheck -e SC1090 -s sh -- \ - ksh/shrc.d/*.sh -shellcheck -e SC1090 -s ksh -- \ - ksh/kshrc \ - ksh/kshrc.d/*.ksh +find ksh \ + -type f -name '*.sh' -exec shellcheck -e SC1090 -s sh -- {} + -o \ + -type f -exec shellcheck -e SC1090 -s ksh -- {} + diff --git a/lint/sh.sh b/lint/sh.sh index 4f796b09..89704c0b 100644 --- a/lint/sh.sh +++ b/lint/sh.sh @@ -1,6 +1,6 @@ -shellcheck -e SC1090 -s sh -- \ - sh/profile \ - sh/profile.d/* \ - sh/shinit \ - sh/shrc \ - sh/shrc.d/* +find sh \ + keychain/profile.d keychain/shrc.d \ + ksh/shrc.d \ + mpd/profile.d \ + plenv/profile.d plenv/shrc.d \ + -type f -print -exec shellcheck -e SC1090 -s sh -- {} + diff --git a/lint/urxvt.sh b/lint/urxvt.sh index 7c7b1876..507034be 100644 --- a/lint/urxvt.sh +++ b/lint/urxvt.sh @@ -1,2 +1 @@ -perlcritic --brutal -- \ - urxvt/ext/*.pl +find urxvt/ext -type f ! -name '*.pl' -print -exec perlcritic --brutal -- {} \; diff --git a/lint/vim.sh b/lint/vim.sh index 8197217e..6714ac9a 100644 --- a/lint/vim.sh +++ b/lint/vim.sh @@ -1,8 +1,5 @@ -vint -s -- \ - vim/after/ \ - vim/config/ \ - vim/ftdetect/ \ - vim/ftplugin/ \ - vim/indent/ \ - vim/gvimrc \ - vim/vimrc +for v in vim/* ; do + [ "$v" != vim/bundle ] || continue + printf '%s\n' "$v" + vint -s -- "$v" +done diff --git a/lint/xinit.sh b/lint/xinit.sh index cebb59a7..b5ff6937 100644 --- a/lint/xinit.sh +++ b/lint/xinit.sh @@ -1,3 +1 @@ -shellcheck -e SC1090 -s sh -- \ - X/xinitrc \ - X/xinitrc.d/*.sh +find X -type f \( -name xinitrc -o -name '*.sh' \) -print -exec shellcheck -e SC1090 -s sh -- {} + -- cgit v1.2.3 From a469c1ef50d0c03b93add44e50afa5d791855106 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 21:52:24 +1300 Subject: 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. --- Makefile | 2 +- check/bin.sh | 2 +- lint/bin.sh | 6 +++++- 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 -- "$@" -- cgit v1.2.3 From 511e93a6d25e277b37763d7aeda02ede0f288fb0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 22:03:31 +1300 Subject: Correct misleading output for `lint-bin` We haven't checked all of the shell scripts, just the POSIX sh ones, which at present, is all but one of them; han(1df). --- check/bin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check/bin.sh b/check/bin.sh index 87bea709..c3185f19 100644 --- a/check/bin.sh +++ b/check/bin.sh @@ -1,4 +1,4 @@ for bin in bin/*.sh ; do sh -n -- "${bin%.sh}" || exit done -printf 'All shell scripts in bin parsed successfully.\n' +printf 'sh(1) binscripts parsed successfully.\n' -- cgit v1.2.3 From 805f90b6e49e258f2b3642d02e4a11db2dc68634 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 22:04:48 +1300 Subject: Show explicit success message for `lint-bin` We add an `|| exit` short-circuit for the case of `shellcheck` exiting non-zero. --- lint/bin.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lint/bin.sh b/lint/bin.sh index 16facb6a..db74c3dd 100644 --- a/lint/bin.sh +++ b/lint/bin.sh @@ -2,4 +2,5 @@ set -- for sh in bin/*.sh ; do set "$@" "${sh%.sh}" done -shellcheck -e SC1090 -- "$@" +shellcheck -e SC1090 -- "$@" || exit +printf 'sh(1) binscripts linted successfully.\n' -- cgit v1.2.3 From 4cf6ed691373bd3cd0c84369e48f735db8d8fd30 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 22:05:59 +1300 Subject: Add conditional Bash `check-bin`, `lint-bin` Both blocks are analogues of the POSIX checks, but are wrapped in a conditional so that bash(1) doesn't become a hard dependency of the default `make install` target. --- check/bin.sh | 11 +++++++++++ lint/bin.sh | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/check/bin.sh b/check/bin.sh index c3185f19..d504961d 100644 --- a/check/bin.sh +++ b/check/bin.sh @@ -1,4 +1,15 @@ +# POSIX sh for bin in bin/*.sh ; do sh -n -- "${bin%.sh}" || exit done printf 'sh(1) binscripts parsed successfully.\n' + +# GNU Bash +if command -v bash >/dev/null 2>&1 ; then + for bin in bin/*.bash ; do + bash -n -- "${bin%.bash}" || exit + done + printf 'bash(1) binscripts parsed successfully.\n' +else + printf 'bash(1) not found, skipping checks.\n' +fi diff --git a/lint/bin.sh b/lint/bin.sh index db74c3dd..5c33aa7d 100644 --- a/lint/bin.sh +++ b/lint/bin.sh @@ -1,6 +1,19 @@ +# POSIX sh set -- for sh in bin/*.sh ; do set "$@" "${sh%.sh}" done shellcheck -e SC1090 -- "$@" || exit printf 'sh(1) binscripts linted successfully.\n' + +# GNU Bash +if command -v bash >/dev/null 2>&1 ; then + set -- + for bin in bin/*.bash ; do + set "$@" "${sh%.sh}" + done + shellcheck -e SC1090 -- "$@" || exit + printf 'bash(1) binscripts linted successfully.\n' +else + printf 'bash(1) not found, skipping lint.\n' +fi -- cgit v1.2.3 From 3fc8bcbef147098fd40ad99a83410d6a994d1579 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 22:08:33 +1300 Subject: Correct copypaste errors in `check-bin`, `lint-bin` Use consistent variable names, and strip the correct suffix from the Bash scripts on iteration. --- lint/bin.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lint/bin.sh b/lint/bin.sh index 5c33aa7d..93eb183c 100644 --- a/lint/bin.sh +++ b/lint/bin.sh @@ -1,7 +1,7 @@ # POSIX sh set -- -for sh in bin/*.sh ; do - set "$@" "${sh%.sh}" +for bin in bin/*.sh ; do + set "$@" "${bin%.sh}" done shellcheck -e SC1090 -- "$@" || exit printf 'sh(1) binscripts linted successfully.\n' @@ -10,7 +10,7 @@ printf 'sh(1) binscripts linted successfully.\n' if command -v bash >/dev/null 2>&1 ; then set -- for bin in bin/*.bash ; do - set "$@" "${sh%.sh}" + set "$@" "${bin%.bash}" done shellcheck -e SC1090 -- "$@" || exit printf 'bash(1) binscripts linted successfully.\n' -- 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. --- 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 From 1601f3e9b40b8d13b3094ec324e0e0cd625994c9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 22:31:31 +1300 Subject: Use shell name not command in check/lint messages This is a little bit clearer and nicer to read, I think. --- check/bin.sh | 6 +++--- lint/bin.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/check/bin.sh b/check/bin.sh index d504961d..08b12778 100644 --- a/check/bin.sh +++ b/check/bin.sh @@ -2,14 +2,14 @@ for bin in bin/*.sh ; do sh -n -- "${bin%.sh}" || exit done -printf 'sh(1) binscripts parsed successfully.\n' +printf 'POSIX sh binscripts parsed successfully.\n' # GNU Bash if command -v bash >/dev/null 2>&1 ; then for bin in bin/*.bash ; do bash -n -- "${bin%.bash}" || exit done - printf 'bash(1) binscripts parsed successfully.\n' + printf 'GNU Bash binscripts parsed successfully.\n' else - printf 'bash(1) not found, skipping checks.\n' + printf 'bash(1) not found, skipping GNU Bash checks.\n' fi diff --git a/lint/bin.sh b/lint/bin.sh index 93eb183c..05a0deba 100644 --- a/lint/bin.sh +++ b/lint/bin.sh @@ -4,7 +4,7 @@ for bin in bin/*.sh ; do set "$@" "${bin%.sh}" done shellcheck -e SC1090 -- "$@" || exit -printf 'sh(1) binscripts linted successfully.\n' +printf 'POSIX sh binscripts linted successfully.\n' # GNU Bash if command -v bash >/dev/null 2>&1 ; then @@ -13,7 +13,7 @@ if command -v bash >/dev/null 2>&1 ; then set "$@" "${bin%.bash}" done shellcheck -e SC1090 -- "$@" || exit - printf 'bash(1) binscripts linted successfully.\n' + printf 'GNU Bash binscripts linted successfully.\n' else - printf 'bash(1) not found, skipping lint.\n' + printf 'bash(1) not found, skipping GNU Bash lint.\n' fi -- cgit v1.2.3 From e7213cb7cbd3149377cf6c08dc9c3813c99743f8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 22:32:49 +1300 Subject: Tidy and correct linting for all three shells Reduce each one to target only the dotfiles specifically for that shell, as opposed to previously where for example the `check-sh` target was checking shell shims in for `mpd` and `plenv`. I'm still not completely sure that's the right approach, but it's at least less conceptually muddy than what we had before. Notably, the check and lint for Korn shell includes a single POSIX shell script file in its `shrc.d` subdirectory, so that check is executed separately. --- check/bash.sh | 14 ++++++++++---- check/ksh.sh | 11 +++++++---- check/sh.sh | 19 +++++++++---------- lint/bash.sh | 10 +++++++++- lint/ksh.sh | 9 ++++++--- lint/sh.sh | 14 ++++++++------ 6 files changed, 49 insertions(+), 28 deletions(-) diff --git a/check/bash.sh b/check/bash.sh index a3efccb1..1f9e1b38 100644 --- a/check/bash.sh +++ b/check/bash.sh @@ -1,5 +1,11 @@ -for bash in bash/* bash/bashrc.d/* ; do - [ -f "$bash" ] || continue - bash -n "$bash" || exit +set \ + bash/bash_completion \ + bash/bash_completion.d/*.bash \ + bash/bash_logout \ + bash/bash_profile \ + bash/bashrc \ + bash/bashrc.d/*.bash +for bash ; do + bash -n -- "$bash" || exit done -printf 'All bash(1) scripts parsed successfully.\n' +printf 'GNU Bash dotfiles parsed successfully.\n' diff --git a/check/ksh.sh b/check/ksh.sh index 51e71e19..f4bade82 100644 --- a/check/ksh.sh +++ b/check/ksh.sh @@ -1,5 +1,8 @@ -for ksh in ksh/* ksh/kshrc.d/* ; do - [ -f "$ksh" ] || continue - ksh -n "$ksh" || exit +set \ + ksh/kshrc \ + ksh/kshrc.d/*.ksh +for ksh ; do + ksh -n -- "$ksh" || exit done -printf 'All ksh scripts parsed successfully.\n' +sh -n -- ksh/shrc.d/ksh.sh || exit +printf 'Korn shell dotfiles parsed successfully.\n' diff --git a/check/sh.sh b/check/sh.sh index c5a86955..92910c11 100644 --- a/check/sh.sh +++ b/check/sh.sh @@ -1,11 +1,10 @@ -for sh in \ - sh/* sh/profile.d/* sh/shrc.d/* \ - keychain/profile.d/* keychain/shrc.d/* \ - ksh/shrc.d/* \ - mpd/profile.d/* \ - plenv/profile.d/* plenv/shrc.d/* \ -; do - [ -f "$sh" ] || continue - sh -n "$sh" || exit +set \ + sh/profile \ + sh/profile.d/*.sh \ + sh/shinit \ + sh/shrc \ + sh/shrc.d/*.sh +for sh ; do + sh -n -- "$sh" || exit done -printf 'All sh(1) scripts parsed successfully.\n' +printf 'POSIX shell dotfiles parsed successfully.\n' diff --git a/lint/bash.sh b/lint/bash.sh index 2fe1ba13..6457da35 100644 --- a/lint/bash.sh +++ b/lint/bash.sh @@ -1 +1,9 @@ -find bash -type f -print -exec shellcheck -e SC1090 -s bash -- {} + +set \ + bash/bash_completion \ + bash/bash_completion.d/*.bash \ + bash/bash_logout \ + bash/bash_profile \ + bash/bashrc \ + bash/bashrc.d/*.bash +shellcheck -e SC1090 -s bash -- "$@" || exit +printf 'GNU Bash dotfiles linted successfully.\n' diff --git a/lint/ksh.sh b/lint/ksh.sh index 4cedc6f7..102e0e54 100644 --- a/lint/ksh.sh +++ b/lint/ksh.sh @@ -1,3 +1,6 @@ -find ksh \ - -type f -name '*.sh' -exec shellcheck -e SC1090 -s sh -- {} + -o \ - -type f -exec shellcheck -e SC1090 -s ksh -- {} + +set \ + ksh/kshrc \ + ksh/kshrc.d/*.ksh +shellcheck -e SC1090 -s ksh -- "$@" || exit +shellcheck -e SC1090 -s sh -- ksh/shrc.d/ksh.sh || exit +printf 'Korn shell dotfiles linted successfully.\n' diff --git a/lint/sh.sh b/lint/sh.sh index 89704c0b..c1c972c8 100644 --- a/lint/sh.sh +++ b/lint/sh.sh @@ -1,6 +1,8 @@ -find sh \ - keychain/profile.d keychain/shrc.d \ - ksh/shrc.d \ - mpd/profile.d \ - plenv/profile.d plenv/shrc.d \ - -type f -print -exec shellcheck -e SC1090 -s sh -- {} + +set \ + sh/profile \ + sh/profile.d/*.sh \ + sh/shinit \ + sh/shrc \ + sh/shrc.d/*.sh +shellcheck -e SC1090 -s sh -- "$@" || exit +printf 'POSIX shell dotfiles linted successfully.\n' -- cgit v1.2.3 From fd2a4778962ac9ff26df251d52d29ce4a7cdc7d9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 22:38:00 +1300 Subject: Apply revisions to `check-zsh` target as well I forgot about this one. --- check/zsh.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/check/zsh.sh b/check/zsh.sh index 50335d56..ce209584 100644 --- a/check/zsh.sh +++ b/check/zsh.sh @@ -1,5 +1,9 @@ -for zsh in zsh/* zsh/zshrc.d/* ; do - [ -f "$zsh" ] || continue - zsh -n "$zsh" || exit +set \ + zsh/zprofile \ + zsh/zshrc.d/*.zsh \ + zsh/zshrc +for zsh ; do + zsh -n -- "$zsh" || exit done -printf 'All zsh(1) scripts parsed successfully.\n' +sh -n zsh/profile.d/zsh.sh || exit +printf 'Z shell dotfiles parsed 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/bin.sh | 4 ++-- lint/games.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lint/bin.sh b/lint/bin.sh index 05a0deba..d27494dd 100644 --- a/lint/bin.sh +++ b/lint/bin.sh @@ -1,7 +1,7 @@ # POSIX sh set -- for bin in bin/*.sh ; do - set "$@" "${bin%.sh}" + set -- "$@" "${bin%.sh}" done shellcheck -e SC1090 -- "$@" || exit printf 'POSIX sh binscripts linted successfully.\n' @@ -10,7 +10,7 @@ printf 'POSIX sh binscripts linted successfully.\n' if command -v bash >/dev/null 2>&1 ; then set -- for bin in bin/*.bash ; do - set "$@" "${bin%.bash}" + set -- "$@" "${bin%.bash}" done shellcheck -e SC1090 -- "$@" || exit printf 'GNU Bash binscripts linted successfully.\n' 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 3e540185b71e7a3bfa9348a13691bf40569a06aa Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 22:44:56 +1300 Subject: Check and lint URxvt Perls correctly Require that the URxvt Perls are built correctly. There's only one at the moment, so I'll make that the single prerequisite for the `check-urxvt` target. --- Makefile | 2 +- check/urxvt.sh | 7 ++++--- lint/urxvt.sh | 7 ++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 84da1d44..5b316294 100644 --- a/Makefile +++ b/Makefile @@ -556,7 +556,7 @@ check-login-shell: check-sh: sh check/sh.sh -check-urxvt: +check-urxvt: urxvt/ext/select sh check/urxvt.sh check-xinit: diff --git a/check/urxvt.sh b/check/urxvt.sh index ee39e6c9..9fff4502 100644 --- a/check/urxvt.sh +++ b/check/urxvt.sh @@ -1,4 +1,5 @@ -for perl in urxvt/ext/*.pl ; do - perl -c "$perl" || exit +set -- urxvt/ext/*.pl +for perl ; do + perl -c "${perl%.pl}" || exit done -printf 'All Perl scripts in urxvt/ext parsed successfully.\n' +printf 'URxvt Perl extensions parsed successfully.\n' diff --git a/lint/urxvt.sh b/lint/urxvt.sh index 507034be..477157f7 100644 --- a/lint/urxvt.sh +++ b/lint/urxvt.sh @@ -1 +1,6 @@ -find urxvt/ext -type f ! -name '*.pl' -print -exec perlcritic --brutal -- {} \; +set -- +for pl in urxvt/ext/*.pl ; do + set -- "$@" "${pl%.pl}" +done +perlcritic --brutal -- "${pl%.pl}" +printf 'URxvt Perl extensions linted successfully.\n' -- cgit v1.2.3 From c7b833ff1cfb189f3d841f376f480b478a6bec49 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 22:51:42 +1300 Subject: Inline check arguments for URxvt perls There's no point making a list out of just one globbed item; we'll just inline it. That's also done for some of the other `check` scripts anyway. --- check/urxvt.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/check/urxvt.sh b/check/urxvt.sh index 9fff4502..4a9e7501 100644 --- a/check/urxvt.sh +++ b/check/urxvt.sh @@ -1,5 +1,4 @@ -set -- urxvt/ext/*.pl -for perl ; do +for perl in urxvt/ext/*.pl ; do perl -c "${perl%.pl}" || exit done printf 'URxvt Perl extensions parsed successfully.\n' -- cgit v1.2.3 From 7464d425b4906f707e034734e9747cabafa9b3a4 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 22:52:34 +1300 Subject: Revamp `lint-vim` target for consistency Use a positive list of things to check rather than just excluding `bundle`; it's a little clearer what it's doing that way, and easier to add paths to check rather than paths to exclude. We also correctly leverage `vint` accepting multiple arguments, like `shellcheck`. --- lint/vim.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lint/vim.sh b/lint/vim.sh index 6714ac9a..d876d770 100644 --- a/lint/vim.sh +++ b/lint/vim.sh @@ -1,5 +1,10 @@ -for v in vim/* ; do - [ "$v" != vim/bundle ] || continue - printf '%s\n' "$v" - vint -s -- "$v" -done +set -- \ + vim/after \ + vim/config \ + vim/ftdetect \ + vim/ftplugin \ + vim/gvimrc \ + vim/indent \ + vim/vimrc +vint -s -- "$@" || exit +printf 'Vim configuration linted successfully.\n' -- cgit v1.2.3 From eda089748e6d512f0497452d6743a0e88c9649f4 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 22:56:20 +1300 Subject: Bring Xinit check/lint scripts up to standard This makes them more consistent with the work already done on the check and lint scripts for the other targets. --- check/xinit.sh | 9 ++++++--- lint/xinit.sh | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/check/xinit.sh b/check/xinit.sh index f8116908..fa235c9d 100644 --- a/check/xinit.sh +++ b/check/xinit.sh @@ -1,4 +1,7 @@ -for xinit in X/xinitrc X/xinitrc.d/*.sh ; do - sh -n "$xinit" || exit +set \ + X/xinitrc \ + X/xinitrc.d/*.sh +for xinit ; do + sh -n -- "$xinit" || exit done -printf 'X/xinitrc and all shell scripts in X/xinitrc.d parsed successfully.\n' +printf 'Xinit startup scripts parsed successfully.\n' diff --git a/lint/xinit.sh b/lint/xinit.sh index b5ff6937..b2718874 100644 --- a/lint/xinit.sh +++ b/lint/xinit.sh @@ -1 +1,5 @@ -find X -type f \( -name xinitrc -o -name '*.sh' \) -print -exec shellcheck -e SC1090 -s sh -- {} + +set \ + X/xinitrc \ + X/xinitrc.d/*.sh +shellcheck -e SC1090 -s sh -- "$@" +printf 'Xinit startup scripts linted successfully.\n' -- cgit v1.2.3 From 3cb22c45009402e5eca066ba7cc7c66fea105e03 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 23:00:47 +1300 Subject: Add idea and issue regarding checking and linting Just for future reference, but the work for this branch is done now. --- IDEAS.md | 3 +++ ISSUES.md | 2 ++ 2 files changed, 5 insertions(+) diff --git a/IDEAS.md b/IDEAS.md index 0a812167..6bb4af82 100644 --- a/IDEAS.md +++ b/IDEAS.md @@ -21,3 +21,6 @@ Ideas calls that via `eval`. * The BigFileMeasures() function in .vim/config/bigfile.vim should maybe be a self-contained plugin rather than a config subfile. +* Ideally, the .awk and/or .sed scripts in the bin and games dirs should be + syntax-checked or linted. I could at least add some patient application of + appropriate `gawk --lint` calls for each of the .awk scripts. diff --git a/ISSUES.md b/ISSUES.md index 48007919..77e0b1d9 100644 --- a/ISSUES.md +++ b/ISSUES.md @@ -22,3 +22,5 @@ Known issues `completion-ignore-case` setting * Document `install-conf` target once I'm sure it's not a dumb idea * Need to decide whether I care about XDG, and implement it if I do +* Need to decide whether I'm testing the shell snippets for MPD, Keychain + etc, and if so how. -- 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. --- check/games.sh | 2 +- lint/bin.sh | 2 +- lint/games.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/check/games.sh b/check/games.sh index 7d1c3694..cb1bcc31 100644 --- a/check/games.sh +++ b/check/games.sh @@ -2,4 +2,4 @@ for game in games/*.sh ; do sh -n -- "${game%.sh}" || exit done -printf 'sh(1) games parsed successfully.\n' +printf 'POSIX sh games parsed successfully.\n' diff --git a/lint/bin.sh b/lint/bin.sh index d27494dd..6037ca55 100644 --- a/lint/bin.sh +++ b/lint/bin.sh @@ -4,7 +4,7 @@ for bin in bin/*.sh ; do set -- "$@" "${bin%.sh}" done shellcheck -e SC1090 -- "$@" || exit -printf 'POSIX sh binscripts linted successfully.\n' +printf 'POSIX shell binscripts linted successfully.\n' # GNU Bash if command -v bash >/dev/null 2>&1 ; then 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 From 0acd1d14c52603bf0c280e4172a63ef7f776d0a2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Oct 2017 23:05:56 +1300 Subject: Bump version number to 0.2.0 --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 85545e1d..ce2c4184 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v0.1.0 -Tue Oct 31 06:16:09 UTC 2017 +tejr dotfiles v0.2.0 +Tue Oct 31 10:05:44 UTC 2017 -- cgit v1.2.3