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