-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint-manpages.sh
executable file
·108 lines (93 loc) · 1.75 KB
/
lint-manpages.sh
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
extract_variable () {
(
cat ../Makefile
cat <<EOF
print_variable:
@\$(foreach b,\$($1),echo XXX \$(b:\$X=) YYY;)
EOF
) |
make -C .. -f - print_variable 2>/dev/null |
sed -n -e 's/.*XXX \(.*\) YYY.*/\1/p'
}
check_missing_docs () (
ret=0
for v in $ALL_COMMANDS
do
case "$v" in
git-merge-octopus) continue;;
git-merge-ours) continue;;
git-merge-recursive) continue;;
git-merge-resolve) continue;;
git-merge-subtree) continue;;
git-fsck-objects) continue;;
git-init-db) continue;;
git-remote-*) continue;;
git-stage) continue;;
git-legacy-*) continue;;
git-?*--?* ) continue ;;
esac
if ! test -f "$v.txt"
then
echo "no doc: $v"
ret=1
fi
if ! sed -e '1,/^### command list/d' -e '/^#/d' ../command-list.txt |
grep -q "^$v[ ]"
then
case "$v" in
git)
;;
*)
echo "no link: $v"
ret=1
;;
esac
fi
done
exit $ret
)
check_extraneous_docs () {
(
sed -e '1,/^### command list/d' \
-e '/^#/d' \
-e '/guide$/d' \
-e '/interfaces$/d' \
-e 's/[ ].*//' \
-e 's/^/listed /' ../command-list.txt
make print-man1 |
grep '\.txt$' |
sed -e 's|^|documented |' \
-e 's/\.txt//'
) | (
all_commands="$(printf "%s " "$ALL_COMMANDS" "$BUILT_INS" "$EXCLUDED_PROGRAMS" | tr '\n' ' ')"
ret=0
while read how cmd
do
case " $all_commands " in
*" $cmd "*) ;;
*)
echo "removed but $how: $cmd"
ret=1;;
esac
done
exit $ret
)
}
BUILT_INS="$(extract_variable BUILT_INS)"
ALL_COMMANDS="$(extract_variable ALL_COMMANDS)"
EXCLUDED_PROGRAMS="$(extract_variable EXCLUDED_PROGRAMS)"
findings=$(
if ! check_missing_docs
then
ret=1
fi
if ! check_extraneous_docs
then
ret=1
fi
exit $ret
)
ret=$?
printf "%s" "$findings" | sort
exit $ret