aboutsummaryrefslogtreecommitdiffhomepage
path: root/markup/pod/live-manual/media/text/bin/check-spelling.sh
blob: b11e2aedd840743cbd303f10a9d9291cb9c2b777 (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh

set -e

# Script to check English spelling interactively in live-manual.

# Check whether aspell is installed or not with English dictionaries.

if [ ! -x "$(which aspell 2>/dev/null)" ]
    then 
        echo "E: aspell - command not found!"
		echo "I: aspell can be downloaded from ftp://ftp.gnu.org/gnu/aspell/"
		echo "I: On debian based systems, aspell can be installed with 'apt-get install aspell'."
		exit 1
elif [ ! -e "/var/lib/dictionaries-common/aspell/aspell-en" ]
	then
		echo "E: No English dictionary found." 
		echo "I: Please do 'apt-get install aspell-en'."
		exit 1
fi

echo ""
echo "This script can help you check the spelling of these English texts:"
echo ""

# Functions

Check_file ()
{
aspell --check "manual/en/${FILE}" --dont-backup --lang="en"
}

List_files ()
{
ls manual/en | cat --number
printf "\tdebian/changelog"
}

Select_files ()
{
echo ""
echo "Choose a number ['a' to see all] ['c' for changelog] or ['q' to quit]:"

read NUMBER

FILE=$(ls manual/en | cat --number | grep -w ${NUMBER} | sed -e 's|[0-9]*||g' -e 's|^[ \t]*||')

case "$NUMBER" in
    [[:digit:]]*)
				Check_file
				;;

	a)
		echo "Checking all files, one at a time..."
		sleep 2
		for FILE in $(ls manual/en)
			do
				Check_file
			done
		;;
    
	c) 
		echo "Checking spelling in debian/changelog"
		sleep 2
		aspell --check "debian/changelog" --dont-backup --lang="en"
		;;
        
	q)	
		exit 0 
		;;

	*)	
		echo "Nothing to do! Exiting..." 
		;;
		
esac
}

List_files
Select_files