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

Daniel Duarte's avatar
debug    
Daniel Duarte committed
4

Daniel Duarte's avatar
Daniel Duarte committed
5
function readAspellOptions {
Daniel Duarte's avatar
cat    
Daniel Duarte committed
6
	options=`cat aspellOptions.txt`
Daniel Duarte's avatar
debug    
Daniel Duarte committed
7
	aspellOptions+=$options
8
	echo "using the following aspell command:"
Daniel Duarte's avatar
debug    
Daniel Duarte committed
9
	echo $aspellOptions
10
	echo 
Daniel Duarte's avatar
Daniel Duarte committed
11
12
}

Daniel Duarte's avatar
Daniel Duarte committed
13
14
echo "Spell checking"
spell_check_code=0
Daniel Duarte's avatar
debug    
Daniel Duarte committed
15

Daniel Duarte's avatar
debug    
Daniel Duarte committed
16
17
18
version=`aspell --version`
echo $version

Daniel Duarte's avatar
debug    
Daniel Duarte committed
19
20

aspellOptions="aspell "
Daniel Duarte's avatar
Daniel Duarte committed
21
readAspellOptions
Daniel Duarte's avatar
Daniel Duarte committed
22

Daniel Duarte's avatar
Daniel Duarte committed
23
for x in $(find spellCheck/ -name '*.md');
Daniel Duarte's avatar
Daniel Duarte committed
24
do	
Daniel Duarte's avatar
Daniel Duarte committed
25
	lines=`cat $x | $aspellOptions list 2>errors.txt |wc -l`
Daniel Duarte's avatar
Daniel Duarte committed
26
27
28
	if [ $lines -gt 0 ]
	then
		echo $x:
Daniel Duarte's avatar
Daniel Duarte committed
29
		cat $x | $aspellOptions list
Daniel Duarte's avatar
Daniel Duarte committed
30
31
32
33
		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
34
	lines=`cat errors.txt | wc -l`
Daniel Duarte's avatar
Daniel Duarte committed
35
36
	if [ $lines -gt 0 ]
	then
Daniel Duarte's avatar
Daniel Duarte committed
37
		cat errors.txt
Daniel Duarte's avatar
Daniel Duarte committed
38
39
40
41
42
43
44
45
		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
46

Daniel Duarte's avatar
Daniel Duarte committed
47
48
rm errors.txt
exit $spell_check_code