#!/bin/sh
#
# Version of style by rig@eng.umd.edu  9/28/1993.
# Based on the Berkeley 4.5 style of 82/11/06.
# Leaves in deroff options even though they don't appear in our 
# deroff man page anyway.
# Selectively invokes deroff or detex according to the name with which
# program is called.

PATH=~rig/bin/tex:/usr/local/lib:/bin:/usr/bin

echo " " $*
sflag=-s
eflag=
Pflag=
nflag=
lflag=
lcon=
rflag=
rcon=
mflag=-me
mlflag=-ml
kflag=
for i in $*
do case $i in
-r) rflag=-r; shift; rcon=$1;shift;continue;;
-l)lflag=-l; shift; lcon=$1;shift;continue;;
-mm) mflag=-mm;shift;continue;;
-ms) mflag=-ms;shift;continue;;
-me) mflag=-me;shift;continue;;
-ma) mflag=-ma;shift;continue;;
-li|-ml) mlflag=-ml;shift;continue;;
+li|-tt)mlflag=;shift;continue;;
-p) sflag=-p;shift;continue;;
-a) sflag=-a;shift;continue;;
-e) eflag=-e;shift;continue;;
-P) Pflag=-P;shift;continue;;
-n) nflag=-n;shift;continue;;
-N) nflag=-N;shift;continue;;
-k) kflag=-k;shift;continue;;
-flags) echo $0 "[-flags] [-r num] [-l num] [-e] [-p] [-n] [-N] [-a] [-P] [-mm|-ms] [-li|+li] [file ...]";exit;;
-*) echo unknown style flag $i; exit;;
*) break;;
esac
done

case $0 in
*stroff|*/stroff)
	deroff $kflag $mflag $mlflag $*^style1^style2^style3 $rflag $rcon $lflag $lcon $sflag $nflag $eflag $Pflag
	exit
        ;;
*stlatex|*/stlatex)
	DE="detex -l"
	;;
*sttex|*/sttex)
	DE="detex"
	;;
*st|*/st)
	DE=cat
	;;
*)
	echo "st[latex|tex|roff]: can't figure out how to be $0" 2>&1
	exit 1
	;;
esac

$DE $*^style1^style2^style3 $rflag $rcon $lflag $lcon $sflag $nflag $eflag $Pflag
