-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathcheck_links.sh
More file actions
executable file
·52 lines (44 loc) · 1.2 KB
/
check_links.sh
File metadata and controls
executable file
·52 lines (44 loc) · 1.2 KB
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
#!/bin/bash
usage() {
echo ""
echo "Usage: $(basename $0) <index> <src>"
echo " <index> Index.html file to start link scanning at."
echo " <src> Directory with doxygen source files."
echo ""
}
if [ ! -f "$1" ]; then
if [ -z "$1" ]; then
echo "No index file provided!" >&2
else
echo "Index file not found: '$1'" >&2
fi
usage
exit 1
fi
if [ ! -d "$2" ]; then
if [ -z "$2" ]; then
echo "No source directory provided!" >&2
else
echo "Source dir not found: '$2'" >&2
fi
usage
exit 1
fi
linkchecker -F csv --timeout 3 --check-extern $1
OFS=$IFS
IFS=$'\n'
for line in $(grep -E '^[^#]' linkchecker-out.csv | tail -n +2); do
link=$(echo $line | cut -d';' -f 1)
msg=$(echo $line | cut -d';' -f 4)
origin=$(grep -Ern "href=['\"]${link}['\"]" $2)
for o in $origin; do
ofile=$(echo $o | cut -d':' -f 1)
oline=$(echo $o | cut -d':' -f 2)
match=$(echo $o | cut -d':' -f 3-)
rest="${match#*$link}"
ocolumn=$((${#match} - ${#rest} - ${#link}))
echo "$(readlink -f -n $ofile):${oline}:${ocolumn};${link};${msg};URL '${link}' results to '${msg}'" >&2
done
done
IFS=$OFS
exit 0