Documentation/lint-manpages: bubble up errors

The "lint-manpages.sh" script does not return an error in case any of its checks fail. While this is faithful to the implementation that we had as part of the "check-docs" target before the preceding commit, it makes it hard to spot any violations of the rules via the corresponding CI job, which will of course exit successfully, too. Adapt the script to bubble up errors. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jun 6, 2024 at 10:01 UTC 64239209743d4b07518786400290f58d1955eeb9
1 file changed +33 -8
Documentation/lint-manpages.sh
+33 -8
@@ -12,7 +12,9 @@ EOF
12 sed -n -e 's/.*XXX \(.*\) YYY.*/\1/p'
13 }
14
15 -check_missing_docs () {
15 +check_missing_docs () (
16 + ret=0
17 +
18 for v in $ALL_COMMANDS
19 do
20 case "$v" in
@@ -32,6 +34,7 @@ check_missing_docs () {
34 if ! test -f "$v.txt"
35 then
36 echo "no doc: $v"
37 + ret=1
38 fi
39
40 if ! sed -e '1,/^### command list/d' -e '/^#/d' ../command-list.txt |
@@ -41,11 +44,15 @@ check_missing_docs () {
44 git)
45 ;;
46 *)
44 - echo "no link: $v";;
47 + echo "no link: $v"
48 + ret=1
49 + ;;
50 esac
51 fi
52 done
48 -}
53 +
54 + exit $ret
55 +)
56
57 check_extraneous_docs () {
58 (
@@ -61,15 +68,19 @@ check_extraneous_docs () {
68 -e 's/\.txt//'
69 ) | (
70 all_commands="$(printf "%s " "$ALL_COMMANDS" "$BUILT_INS" "$EXCLUDED_PROGRAMS" | tr '\n' ' ')"
71 + ret=0
72
73 while read how cmd
74 do
75 case " $all_commands " in
76 *" $cmd "*) ;;
77 *)
70 - echo "removed but $how: $cmd";;
78 + echo "removed but $how: $cmd"
79 + ret=1;;
80 esac
81 done
82 +
83 + exit $ret
84 )
85 }
86
@@ -77,7 +88,21 @@ BUILT_INS="$(extract_variable BUILT_INS)"
88 ALL_COMMANDS="$(extract_variable ALL_COMMANDS)"
89 EXCLUDED_PROGRAMS="$(extract_variable EXCLUDED_PROGRAMS)"
90
80 -{
81 - check_missing_docs
82 - check_extraneous_docs
83 -} | sort
91 +findings=$(
92 + if ! check_missing_docs
93 + then
94 + ret=1
95 + fi
96 +
97 + if ! check_extraneous_docs
98 + then
99 + ret=1
100 + fi
101 +
102 + exit $ret
103 +)
104 +ret=$?
105 +
106 +printf "%s" "$findings" | sort
107 +
108 +exit $ret