blob: ff1df2a4590dfc0e179b39266b70d73db9edf72e (
plain) (
blame)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#!/bin/sh
set -eu
sort_dicts() {
for f in doc/spelling/*.txt; do
if ! LANG=POSIX sort "$f" | diff - "$f"; then
if [ "$IN_PLACE" = true ]; then
OUT="$(mktemp)"
LANG=POSIX sort "$f" | uniq > "$OUT"
mv "$OUT" "$f"
else
echo "The $f dictionary is unsorted. To fix it, run:" >&2
echo " sh aux/workflow/assert-spelling.sh -i" >&2
exit 1
fi
fi
done
}
IN_PLACE=false
while getopts 'l:i' flag; do
case "$flag" in
l)
LANGS="$OPTARG"
;;
i)
IN_PLACE=true
sort_dicts
exit
;;
*)
exit 2
;;
esac
done
if [ -z "${LANGS:-}" ]; then
echo 'Missing -l LANGS' >&2
exit 2
fi
mkdir -p doc/spelling
eval "touch doc/spelling/{international,$(echo "$LANGS" | tr ' ' ,)}.txt"
get_lang() {
grep lang=.. "$1" | \
head -n1 | \
awk '
match($0, /lang="(..)"/) {
print substr($0, RSTART+length("lang=\""), 2)
}
'
}
ACC="$(mktemp)"
# shellcheck disable=2044
for f in $(find public -type f -name '*.html'); do
l="$(get_lang "$f")"
CURR_DICT="$(mktemp)"
cat doc/spelling/international.txt "doc/spelling/$l.txt" | sort | uniq > "$CURR_DICT"
hunspell -u3 -H -d "$l" -p "$CURR_DICT" "$f" | tee -a "$ACC" >&2
done
if [ -s "$ACC" ]; then
printf '\n\tMispelled words detected by hunspell above.\n\n' >&2
exit 1
fi
sort_dicts
|