forked from flux-framework/rfc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spellcheck
executable file
·47 lines (41 loc) · 994 Bytes
/
spellcheck
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
#!/bin/bash
if test $man_base_dir; then
set ${man_base_dir}/man*/*.adoc
fi
if test $# == 0; then
echo "Usage: spellcheck file [file...]" >&2
exit 1
fi
dict=${pws_dict:-./spell.en.pws}
if ! test -r $dict; then
echo Dictionary $dict not found >&2
exit 1
fi
if test -z "$ASPELL"; then
echo "1..$# # skip because aspell is not installed"
exit 0
fi
if ! $ASPELL -n list </dev/null >/dev/null; then
echo "1..$# # skip because aspell dry run failed"
exit 0
fi
exit_val=0
echo "1..$#"
count=1
for f in $*; do
filename=$(basename $f)
dir=$(basename $(dirname $f))
tmpfile=$(mktemp)
rc=$(cat $f | $ASPELL -p $dict -n list | sort | uniq | tee $tmpfile | wc -l)
if test $rc == 0; then
echo "ok $count - spell check $dir/$filename"
else
echo "not ok $count - spell check $dir/$filename failed"
echo "---"
exit_val=1
fi
cat $tmpfile | sed -e "s!^!$(basename $f): !"
rm -f $tmpfile
((count++))
done
exit $exit_val