Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 76 lines (68 sloc) 1.832 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
#!/bin/bash
#
# Find all man pages, and check they do not have groff syntax errors
# or warnings.
#
# Sami Kerola <kerolasa@iki.fi>

set -e # exit on errors
set -o pipefail # exit if pipe writer fails
set -u # disallow usage of unset variables
set -C # disallow redirection file overwriting
SCRIPT_INVOCATION_SHORT_NAME=$(basename ${0})
trap 'echo "${SCRIPT_INVOCATION_SHORT_NAME}: exit on error"; exit 1' ERR

usage() {
echo "Usage: ${0} [-ph]"
echo " -p print file names before checking"
}

PRINT_FILE_NAMES='false'
while getopts ph OPTIONS; do
case ${OPTIONS} in
p)
PRINT_FILE_NAMES='true'
;;
h)
usage
exit 0
;;
*)
usage
exit 1
esac
done

ERROR_FILE=$(mktemp ${SCRIPT_INVOCATION_SHORT_NAME}.XXXXXXXXXX)
# remove tmp file at exit
trap "rm -f ${ERROR_FILE}" 0

for I in $(
find $(git rev-parse --show-toplevel) -name '*.[1-8]' |
egrep -v '(Documentation|.git|/.libs/|autom4te.cache|ru/ddate)'
); do
# FIXME: the determination whether a manual does include
# should probably be somewhat smarter.
IS_INCLUDE=$(wc -w ${I} | awk '{print $1}')
if [ ${IS_INCLUDE} -eq 2 ]; then
# Some manuals, such as x86_64, call include which
# will read system manual. Testing what comes from
# package does not make much sense, so skip doing it.
if ${PRINT_FILE_NAMES}; then
echo "skipping: ${I}"
fi
continue
fi
if ${PRINT_FILE_NAMES}; then
echo "testing: ${I}"
man --warnings=all ${I} >/dev/null
else
man --warnings=all ${I} >/dev/null 2>> ${ERROR_FILE}
fi
done

COUNT_ERRORS=$(awk 'END {print NR}' ${ERROR_FILE})
if [ ${COUNT_ERRORS} -ne 0 ]; then
echo "${SCRIPT_INVOCATION_SHORT_NAME}: failed"
echo "use: $(readlink -f ${0}) -p"
echo " to find where the problems are."
exit 1
fi

if ! ${PRINT_FILE_NAMES}; then
echo "${SCRIPT_INVOCATION_SHORT_NAME}: success"
fi
exit 0
Something went wrong with that request. Please try again.