summaryrefslogtreecommitdiff
path: root/docs/src/checkref
blob: 8b270383a3777d3d04cd46b11c946e55b344aee0 (plain)
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
#!/bin/bash
#set -x

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

LANGUAGE="$1"
shift

FILES="$@"

# it'd be nice to build-depend on checklinks, but it's not available in Lucid
if [ -z $(which checklink) ]; then
    echo "*** checklink not found, install w3c-linkchecker for better coverage" 1>&2
    exit 0
fi


BAD_LINKS=0
for F in $FILES; do
    OUT=.checklink.$LANGUAGE.$(basename $F).tmp
    rm -f $OUT
    checklink --quiet --exclude "http(s?)://" $F | tee $OUT 2>&1
    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