2012-06-02 07:36:43 -05:00
|
|
|
#!/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() {
|
2013-04-08 14:32:53 -05:00
|
|
|
echo "Usage: ${0} [-vVh]"
|
|
|
|
echo " -v verbose messaging"
|
|
|
|
echo " -V print version and exit"
|
|
|
|
echo " -h print this help and exit"
|
2012-06-02 07:36:43 -05:00
|
|
|
}
|
|
|
|
|
2013-04-08 14:32:53 -05:00
|
|
|
VERBOSE='false'
|
|
|
|
while getopts vVh OPTIONS; do
|
2012-06-02 07:36:43 -05:00
|
|
|
case ${OPTIONS} in
|
2013-04-08 14:32:53 -05:00
|
|
|
v)
|
|
|
|
VERBOSE='true'
|
|
|
|
;;
|
|
|
|
V)
|
|
|
|
echo "util-linux: ${SCRIPT_INVOCATION_SHORT_NAME}: 2"
|
|
|
|
exit 0
|
2012-06-02 07:36:43 -05:00
|
|
|
;;
|
|
|
|
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
|
|
|
|
|
2013-04-08 14:32:53 -05:00
|
|
|
COUNT_ERRORS=0
|
|
|
|
declare -a REPEATS
|
|
|
|
declare -A KNOWN_REPEATS
|
|
|
|
KNOWN_REPEATS[mount.8]='foo'
|
|
|
|
KNOWN_REPEATS[sfdisk.8]="0 <c,h,s>"
|
|
|
|
KNOWN_REPEATS[flock.1]='"$0"'
|
|
|
|
KNOWN_REPEATS[switch_root.8]='$DIR'
|
|
|
|
|
|
|
|
remove_repeats()
|
|
|
|
{
|
|
|
|
set +u
|
|
|
|
for KN in ${KNOWN_REPEATS[${I##*/}]}; do
|
|
|
|
if [ "${KN}" = "${REPEATS[$1]}" ]; then
|
|
|
|
if $VERBOSE; then
|
|
|
|
echo "info: ${I} removing repeat: ${REPEATS[$1]}"
|
|
|
|
fi
|
|
|
|
unset REPEATS[$1]
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
set -u
|
|
|
|
}
|
|
|
|
|
2012-06-02 07:36:43 -05:00
|
|
|
for I in $(
|
|
|
|
find $(git rev-parse --show-toplevel) -name '*.[1-8]' |
|
2012-10-08 02:08:07 -05:00
|
|
|
egrep -v '(Documentation|.git|/.libs/|autom4te.cache)'
|
2012-06-02 07:36:43 -05:00
|
|
|
); do
|
2013-04-08 14:32:53 -05:00
|
|
|
if awk '{if (1 < NR) {exit 1}; if ($1 ~ /^.so$/) {exit 0}}' ${I}; then
|
|
|
|
# Some manuals, such as x86_64, call inclusion and they
|
|
|
|
# should not be tested any further.
|
|
|
|
if ${VERBOSE}; then
|
|
|
|
printf "skipping: ${I}: includes "
|
|
|
|
awk '{print $2}' ${I}
|
2012-06-02 07:36:43 -05:00
|
|
|
fi
|
|
|
|
continue
|
|
|
|
fi
|
2013-04-08 14:32:53 -05:00
|
|
|
I_ERR=0
|
|
|
|
if ${VERBOSE}; then
|
2012-06-02 07:36:43 -05:00
|
|
|
echo "testing: ${I}"
|
|
|
|
fi
|
2013-04-08 14:32:53 -05:00
|
|
|
MANWIDTH=80 man --warnings=all ${I} >/dev/null 2>| ${ERROR_FILE}
|
|
|
|
if [ -s ${ERROR_FILE} ]; then
|
|
|
|
echo "error: run: man --warnings=all ${I} >/dev/null" >&2
|
|
|
|
I_ERR=1
|
|
|
|
fi
|
|
|
|
if ! lexgrog ${I} >/dev/null; then
|
|
|
|
echo "error: run: lexgrog ${I}" >&2
|
|
|
|
I_ERR=1
|
|
|
|
fi
|
|
|
|
REPEATS=( $(MANWIDTH=2000 man -l ${I} |
|
|
|
|
col -b |
|
|
|
|
sed -e 's/\s\+/\n/g; /^$/d' |
|
|
|
|
awk 'BEGIN { p="" } { if (0 < length($0)) { if (p == $0) { print } } p = $0 }') )
|
|
|
|
if [ 0 -lt "${#REPEATS[@]}" ]; then
|
|
|
|
ITER=${#REPEATS[@]}
|
|
|
|
while [ -1 -lt ${ITER} ]; do
|
|
|
|
remove_repeats ${ITER}
|
|
|
|
# The 'let' may cause exit on error.
|
|
|
|
# When ITER == 0 -> let returns 1, bash bug?
|
|
|
|
let ITER=${ITER}-1 || true
|
|
|
|
done
|
|
|
|
if [ 0 -lt "${#REPEATS[@]}" ]; then
|
|
|
|
echo "warning: ${I} has repeating words: ${REPEATS[@]}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# The 'let' may cause exit on error.
|
|
|
|
# COUNT_ERRORS=0; let COUNT_ERRORS=$COUNT_ERRORS+0; echo $?
|
|
|
|
# Is this a bash bug?
|
|
|
|
let COUNT_ERRORS=$COUNT_ERRORS+$I_ERR || true
|
2012-06-02 07:36:43 -05:00
|
|
|
done
|
|
|
|
|
|
|
|
if [ ${COUNT_ERRORS} -ne 0 ]; then
|
2013-04-08 14:32:53 -05:00
|
|
|
echo "error: ${SCRIPT_INVOCATION_SHORT_NAME}: ${COUNT_ERRORS} manuals failed" >&2
|
2012-06-02 07:36:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-04-08 14:32:53 -05:00
|
|
|
if ! ${VERBOSE}; then
|
2012-06-02 07:36:43 -05:00
|
|
|
echo "${SCRIPT_INVOCATION_SHORT_NAME}: success"
|
|
|
|
fi
|
2013-04-08 14:32:53 -05:00
|
|
|
|
2012-06-02 07:36:43 -05:00
|
|
|
exit 0
|