File: checkref

package info (click to toggle)
linuxcnc 2.9.0~pre1%2Bgit20230208.f1270d6ed7-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 274,984 kB
  • sloc: python: 142,166; ansic: 103,241; cpp: 99,140; tcl: 16,045; xml: 10,608; sh: 10,124; makefile: 1,229; javascript: 226; sql: 72; asm: 15
file content (49 lines) | stat: -rwxr-xr-x 1,032 bytes parent folder | download | duplicates (3)
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
#!/bin/bash
#set -x

WARN_ON_FAILURE=0
if [ "$1" = "--warn-on-failure" ]; then
    WARN_ON_FAILURE=1
    shift
fi

LANGUAGE="$1"
shift

FILES="$@"

if [ -z $(which linuxcnc-checklink) ]; then
    echo "ERROR: checklink not found, install w3c-linkchecker for HTML link validation" 1>&2
    exit 1
fi


BAD_LINKS=0
for F in $FILES; do
    OUT=.checklink.$LANGUAGE.$(basename $F).tmp
    rm -f $OUT
    linuxcnc-checklink --quiet --exclude "(http|https|irc)://" $F  2>&1 | tee $OUT
    egrep -q 'List of (broken links and other issues|duplicate and empty anchors)' $OUT
    if [ $? -ne 1 ]; then
        BAD_LINKS=1
    fi
    rm -f $OUT
done

if [ $BAD_LINKS -eq 1 ]; then
    RET_VAL=1
    echo "***" 1>&2
    echo "*** warning: bad links found in $LANGUAGE docs!" 1>&2
    if [ $WARN_ON_FAILURE -eq 1 ]; then
        echo "*** oh well, continuing anyway" 1>&2
        RET_VAL=0
    fi
    echo "***" 1>&2
    exit $RET_VAL
else
    echo "###"
    echo "### language: $LANGUAGE"
    echo "### all links are good!"
    echo "###"
fi