aboutsummaryrefslogtreecommitdiff
path: root/check/man.sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-04-05 21:08:39 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-04-05 21:09:19 +1200
commit165c35c70b43349e882bd44be31c0837ab19729b (patch)
tree2a1f4218b78721c3262ac0c0b634629037f50ce6 /check/man.sh
parentRemove mail/mailrc from ignored files (diff)
downloaddotfiles-165c35c70b43349e882bd44be31c0837ab19729b.tar.gz
dotfiles-165c35c70b43349e882bd44be31c0837ab19729b.zip
More sh flexibility (check/lint scripts)
Diffstat (limited to 'check/man.sh')
-rw-r--r--check/man.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/check/man.sh b/check/man.sh
new file mode 100644
index 00000000..89c03890
--- /dev/null
+++ b/check/man.sh
@@ -0,0 +1,47 @@
+# Check that manual pages and logical binaries match up
+
+# Need some scripts from the source directory
+PATH=bin:$PATH
+
+# Create temporary directory and implement cleanup function for it
+td=
+cleanup() {
+ rm -fr -- "$td"
+}
+for sig in EXIT HUP INT TERM ; do
+ trap cleanup "$sig"
+done
+td=$(mktd test-man) || exit
+
+# Get lists of logical binaries and manual pages
+# shellcheck disable=SC2016
+find bin games -type f -print |
+ sed 's_.*/__;s_\..*$__' |
+ sort | uniq > "$td"/bin
+# shellcheck disable=SC2016
+find man/man[168] -type f -name '*.[168]df' -print |
+ sed 's_.*/__;s_\..*$__' |
+ sort | uniq > "$td"/man
+
+# Get lists of noman scripts and nobin manual pages
+comm -23 "$td"/bin "$td"/man > "$td"/noman
+comm -13 "$td"/bin "$td"/man > "$td"/nobin
+
+# Emit the content of both, if any
+ex=0
+if [ -s "$td"/noman ] ; then
+ printf >&2 'No manual pages found for:\n'
+ cat >&2 -- "$td"/noman
+ ex=1
+fi
+if [ -s "$td"/nobin ] ; then
+ printf >&2 'Stray manual page for:\n'
+ cat >&2 -- "$td"/nobin
+ ex=1
+fi
+
+# Exit appropriately
+if [ "$ex" -eq 0 ] ; then
+ printf 'All scripts have manual pages.\n'
+fi
+exit "$ex"