reorganizing the repository
[project-aon.git] / es / xml / ispell-pae.sh
diff --git a/es/xml/ispell-pae.sh b/es/xml/ispell-pae.sh
new file mode 100755 (executable)
index 0000000..58441b1
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/sh -e
+#
+# Do a spell check of PAE files using a standard dictionary
+#
+
+DICTFILE=pae-dict.ispell
+
+check_dict() {
+    [ -r "$DICTFILE" ] && return 0
+    [ -e "$DICTFILE" ] && echo "ERROR: Dictionary file $DICTFILE does not exist. Incomplete checkout?" >&2
+    [ ! -f "$DICTFILE" ] && echo "ERROR: Dictionary file $DICTFILE is not a regular file." >&2
+    return 1
+}
+
+usage() {
+    echo "Usage: $0 book.xml [book2.xml ...]"
+}
+
+if [ -z "$*" ] ; then
+    usage
+    exit 1
+fi
+
+if ! check_dict ; then
+    echo "There was an error with the dictionary file. Aborting" >&2
+    exit 1
+fi
+
+for file in $* ; do
+    if [ -f "$file" ] && [ -r "$file" ] ; then
+        echo "Running spell check for $file"
+        ispell -H -p $DICTFILE $file
+    else
+        echo -n "ERROR: Will not check '$file'" >&2
+        if [ ! -e "$file" ] ; then
+            echo -n " it does not exist." >&2
+        elif [ ! -f "$file" ] ; then
+            echo " it is not a regular file." >&2
+        fi
+        echo
+    fi
+done
+
+exit 0