File: man-lint

package info (click to toggle)
pcp 6.3.8-1
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 235,180 kB
  • sloc: ansic: 1,253,622; sh: 173,998; xml: 160,490; cpp: 83,331; python: 20,482; perl: 18,302; yacc: 6,886; makefile: 2,955; lex: 2,862; fortran: 60; java: 52
file content (58 lines) | stat: -rwxr-xr-x 1,310 bytes parent folder | download
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
#!/bin/sh
#
# man page lint checking, mainly for use in PCP CI builds.
# Usage: scripts/man-lint [-f] <file>...
#
# Note: silently exits if 'mandoc' utility is unavailable.
# Will also (optionally) use 'lexgrog' if it is installed,
# as a secondary static check.
#

which mandoc >/dev/null 2>&1
[ $? -eq 0 ] || exit 0	# not installed

sts=0
exit_sts=true
if [ $# -gt 0 -a "X$1" = X-f ]
then
    # -f => exit status is 0, so don't break the build!
    #
    exit_sts=false
    shift
fi

tmp=`mktemp -d /tmp/pcp.XXXXXXXXX` || exit 1
trap "rm -rf $tmp; exit \$sts" 0 1 2 3 15

# some things reported by mandoc -T lint are just plain bogus,
# or things we are not going to change
#
# the WARNING -> Warning substitution is so that the warnings
# will get picked up by the daily builds (scripts/pcp-daily)
#
mandoc -T lint "$@" \
    | sed \
	-e '/ UNSUPP: /d' \
	-e '/ WARNING: missing date/d' \
	-e '/ WARNING: cannot parse date/d' \
	-e '/ STYLE: input text line longer than 80 bytes/d' \
	-e 's/ WARNING:/ Warning:/' \
> $tmp/mandoc 2>&1
if test -s $tmp/mandoc
then
    $exit_sts && sts=1
    cat $tmp/mandoc	# failure, report issues
fi

if which lexgrog >/dev/null 2>&1
then
    if lexgrog "$@" > $tmp/lexgrog
    then
	:
    else
	$exit_sts && sts=1
	cat $tmp/lexgrog	# failure, report issues
    fi
fi

exit