test_spell_check.sh 903 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
function readAspellOptions {
Daniel Duarte's avatar
Daniel Duarte committed
5
6
7
8
	options=$1
	local jsonOptions="aspell "
	while read line; do jsonOptions=$jsonOptions$line; done < $options
	echo "$jsonOptions"	
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
14
15
aspellOptions=$(readAspellOptions)
echo $aspellOptions
echo "this above is echo"
Daniel Duarte's avatar
Daniel Duarte committed
16

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

Daniel Duarte's avatar
Daniel Duarte committed
41
42
rm errors.txt
exit $spell_check_code