1717
1818
1919BAD_LINKS=0
20+ CHECKED=0
21+ SKIPPED=0
2022for F in " $@ " ; do
2123 OUT=.checklink.$LANGUAGE .$( basename " $F " ) .tmp
2224 rm -f " $OUT "
23- linuxcnc-checklink --quiet --exclude " (http|https|irc)://" " $F " 2>&1 | tee " $OUT "
25+ # --follow-file-links is required: recent w3c-linkchecker refuses file://
26+ # URIs by default, so without it checklink never inspects the local file
27+ # and validates nothing.
28+ linuxcnc-checklink --quiet --follow-file-links --exclude " (http|https|irc)://" " $F " 2>&1 | tee " $OUT "
29+ STATUS=${PIPESTATUS[0]}
30+ # Distinguish "checklink never inspected the file" from "checklink ran and
31+ # found problems". It exits 64 when it reports broken links, so a nonzero
32+ # exit is not itself a failure; only a shell exec failure (126/127) or an
33+ # explicit refusal to read the document means nothing was validated.
34+ if [ " $STATUS " -eq 126 ] || [ " $STATUS " -eq 127 ] || \
35+ grep -E -q " (Access to 'file' URIs has been disabled|checklink not configured)" " $OUT " ; then
36+ echo " *** warning: linuxcnc-checklink could not validate $( basename " $F " ) ; skipped" 1>&2
37+ SKIPPED=$(( SKIPPED + 1 ))
38+ rm -f " $OUT "
39+ continue
40+ fi
41+ CHECKED=$(( CHECKED + 1 ))
2442 if grep -E -q ' List of (broken links and other issues|duplicate and empty anchors)' " $OUT " ; then
2543 BAD_LINKS=1
2644 fi
@@ -37,10 +55,22 @@ if [ $BAD_LINKS -eq 1 ]; then
3755 fi
3856 echo " ***" 1>&2
3957 exit $RET_VAL
58+ elif [ $CHECKED -eq 0 ]; then
59+ # Nothing validated: warn instead of claiming success, but do not fail
60+ # the build (an unusable checklink is an environment problem).
61+ echo " ***" 1>&2
62+ echo " *** warning: link checking skipped for $LANGUAGE docs;" 1>&2
63+ echo " *** linuxcnc-checklink validated no files ($SKIPPED skipped)." 1>&2
64+ echo " *** install w3c-linkchecker and re-run ./configure to enable it." 1>&2
65+ echo " ***" 1>&2
4066else
4167 echo " ###"
4268 echo " ### language: $LANGUAGE "
43- echo " ### all links are good!"
69+ if [ $SKIPPED -gt 0 ]; then
70+ echo " ### checked links are good ($SKIPPED file(s) skipped)!"
71+ else
72+ echo " ### all links are good!"
73+ fi
4474 echo " ###"
4575fi
4676
0 commit comments