Make it possible to generate 29tsoc ebooks
[project-aon.git] / es / xml / ispell-pae.sh
1 #!/bin/sh -e
2 #
3 # Do a spell check of PAE files using a standard dictionary
4 #
5
6 DICTFILE=pae-dict.ispell
7
8 check_dict() {
9     [ -r "$DICTFILE" ] && return 0
10     [ -e "$DICTFILE" ] && echo "ERROR: Dictionary file $DICTFILE does not exist. Incomplete checkout?" >&2
11     [ ! -f "$DICTFILE" ] && echo "ERROR: Dictionary file $DICTFILE is not a regular file." >&2
12     return 1
13 }
14
15 usage() {
16     echo "Usage: $0 book.xml [book2.xml ...]"
17 }
18
19 if [ -z "$*" ] ; then
20     usage
21     exit 1
22 fi
23
24 if ! check_dict ; then
25     echo "There was an error with the dictionary file. Aborting" >&2
26     exit 1
27 fi
28
29 for file in $* ; do
30     if [ -f "$file" ] && [ -r "$file" ] ; then
31         echo "Running spell check for $file"
32         ispell -H -p $DICTFILE $file
33     else
34         echo -n "ERROR: Will not check '$file'" >&2
35         if [ ! -e "$file" ] ; then
36             echo -n " it does not exist." >&2
37         elif [ ! -f "$file" ] ; then
38             echo " it is not a regular file." >&2
39         fi
40         echo
41     fi
42 done
43
44 exit 0