test_spell_check.sh 825 Bytes
Newer Older
Daniel Duarte's avatar
Daniel Duarte committed
1
2
3
#!/bin/bash
set -e

Daniel Duarte's avatar
Daniel Duarte committed
4
aspellOptions="aspell "
Daniel Duarte's avatar
Daniel Duarte committed
5
function readAspellOptions {
Daniel Duarte's avatar
Daniel Duarte committed
6
7
8
	filename=$1
	while read line; do aspellOptions+=$line; done < $filename
	echo "$aspellOptions"
Daniel Duarte's avatar
Daniel Duarte committed
9
10
}

Daniel Duarte's avatar
Daniel Duarte committed
11
12
echo "Spell checking"
spell_check_code=0
Daniel Duarte's avatar
Daniel Duarte committed
13
aspellOptions
Daniel Duarte's avatar
Daniel Duarte committed
14

Daniel Duarte's avatar
Daniel Duarte committed
15
for x in $(find spellCheck/ -name '*.md');
Daniel Duarte's avatar
Daniel Duarte committed
16
do	
Daniel Duarte's avatar
Daniel Duarte committed
17
	lines=`cat $x | $aspellOptions list 2>errors.txt |wc -l`
Daniel Duarte's avatar
Daniel Duarte committed
18
19
20
	if [ $lines -gt 0 ]
	then
		echo $x:
Daniel Duarte's avatar
Daniel Duarte committed
21
		cat $x | $aspellOptions list
Daniel Duarte's avatar
Daniel Duarte committed
22
23
24
25
		spell_check_code=1
		echo 
	fi
# we need to check stderr - in case something really bad happens there will be output there
Daniel Duarte's avatar
Daniel Duarte committed
26
	lines=`cat errors.txt | wc -l`
Daniel Duarte's avatar
Daniel Duarte committed
27
28
	if [ $lines -gt 0 ]
	then
Daniel Duarte's avatar
Daniel Duarte committed
29
		cat errors.txt
Daniel Duarte's avatar
Daniel Duarte committed
30
31
32
33
34
35
36
37
		spell_check_code=1
	fi
done

if [ $spell_check_code -gt 0 ]
then
	echo "Spell check found some problems. Either fix them or add exceptions to the dictionary file: .aspell.en.pws"
fi
Daniel Duarte's avatar
Daniel Duarte committed
38

Daniel Duarte's avatar
Daniel Duarte committed
39
40
rm errors.txt
exit $spell_check_code