[comp.text.tex] texspell

stumpf@gtenmc.UUCP (Jon S. Stumpf) (03/22/90)

I tried using texspell yesterday and discovered it was a C-shell script.
I spent the 20 minutes to rewrite it to the Korn shell and also inserted
comments to convert my rewrite to the Bourne shell for those not fortunate.

This probably already exists but since I didn't have a rewrite and I took
the time to write it myself, I will post it with the idea others are in
a similar situation.

This is *NOT* a shar file.  Just cut and run.  My .signature will probably
be at the end, so snip that too.

jss

---- Cut Here ---- ---- Cut Here ---- ---- Cut Here ---- ---- Cut Here ----
#!/bin/ksh
# shell for running texspell which is TeX and LaTeX's spell
# Author: Kamal Al-Yahya 1984
#
# Rewritten by:  Jon S. Stumpf, 1990
#    Converted to Korn Shell;
#    Error messages go to stderr;
#    Exit status should be in the range [0, 128];
#    Current exit status values are: 0, 1, and whatever detex/spell return
#    If no files given, stdin is read;
#    If files are given, the filename is printed for each;
#    Use getopts for options, however, getopts has annoying error messages
#    Default flags:  +i (i is off), -w (w is on)
#
#    To convert to the Bourne shell, use lines after '#sh' comment and
#        replace #!/bin/ksh with #!/bin/sh.  getopts in the Bourne shell
#        does not understand '+option' syntax so the option defaults are
#        off and must be explicitly turned on.
#

PATH=:/bin:/usr/bin:/usr/local/bin

FUNC_NAME=$(basename ${0})		#sh	FUNC_NAME=`basename ${0}`
USAGE="usage:  ${FUNC_NAME} [ -iw ] [ file ... ]"

DETEX=detex
SPELL=spell

# Set default flags
iflag=""
wflag="w"				#sh	wflag=""

while getopts "iw" option
do
	case ${option} in
	i)	iflag="i";;
	w)	wflag="w";;
	+i)	iflag="";;		#sh	delete this line
	+w)	wflag="";;		#sh	delete this line
	\?)
		print -u2 "${USAGE}"	#sh	echo "${USAGE}" 1>&2
		exit 1
		;;
	esac
done

shift OPTIND-1				#sh	shift `expr ${OPTIND} - 1`

FLAGS="${iflag}${wflag}"

if [[ ! -z ${FLAGS} ]]			#sh	if [ ! -z "${FLAGS}" ]
then
	FLAGS="-${FLAGS}"
fi

if (( ${#} == 0 ))			#sh	if [ ${#} -eq 0 ]
then
	${DETEX} ${FLAGS} | ${SPELL}

	exit $?
fi

for file in "$@"
do
	print -u1 ":::: ${file} ::::"	#sh	echo ":::: ${file} ::::"
	${DETEX} ${FLAGS} "${file}" | ${SPELL}
done

exit $?

---- Cut Here ---- ---- Cut Here ---- ---- Cut Here ---- ---- Cut Here ----
-- 
 jss - Jon S. Stumpf