#!/bin/sh
#
# 	spellhtml: ispell wrapper, see spellhtmlic
#
#	(c) Copyright 2002 Lszl Nmeth, All Rights Reserved
#
#	This program is free software; you can redistribute it and/or
#	modify it under the terms of the GNU General Public License
#	as published by the Free Software Foundation; either version
#	2 of the License, or (at your option) any later version.
#
case $# in
0) echo "Usage: spellhtml [ispell options] html_files" 1>&2; exit 1
esac

OPTIONS="-t"
FILES=""
FILES2=""
j=0

for i
do
    case $i in
    -[VfdpwWT]) OPTIONS="$OPTIONS $i"; j=1 ;;
    -*) OPTIONS="$OPTIONS $i" ;;
    *) if [ $j == "0" ]; then 
		spellhtmlic < $i > /tmp/$i.$$
    		FILES="$FILES /tmp/$i.$$"
		FILES2="$FILES2 $i"
	else 
		OPTIONS="$OPTIONS $i"
		j=0
	fi ;;
    esac
done

ispell $OPTIONS $FILES

for i in $FILES2
do
    case $i in
    [^-]*) 
    	    spellhtmlic < /tmp/$i.$$ > /tmp/$i2.$$ && 
	    mv /tmp/$i2.$$ $i && 
	    rm -f /tmp/$i.$$ /tmp/$i2.$$;;
    esac
done
