#!/bin/sh
#
# Let the user know if the word given as an argument is misspelled
#
# Ispell command line switches-handling added by David Frey <david@eos.lugs.ch>

WORDCHARS=""
# XXX Latin1-centric

ARGS=""
while getopts aAbBcCd:Def:lLMN:p:PsStTw:vV s; do
  case $s in
   a|A|c|e|f|l|L|M|N)	;; # ignored
   b|B|C|n|m|P|S|t|x|V)	ARGS="$ARGS -$s" ;; # pass these options through
   d|p|W|T)         	ARGS="$ARGS -$s $OPTARG" ;; # options with params
   w)			WORDCHARS="$OPTARG" ;; 
  esac
done
shift `expr $OPTIND - 1`

if [ "`echo $1 | ispell -l -w $WORDCHARS $ARGS`" ]; then
        echo "Misspelled"
        exit 1
else
        echo "Correct"
        exit 0
fi
