C=$SHOME/cmd
case $1 in -*) mod=$1; shift;; esac
where=sdata/.help
header=-rq2
case $mod in -*f*) where=.help; header=-rq1;; esac
if test ! -d $where; then echo "Cannot find documentation directory $where"; exit; fi
cd $where
case $1 in
'')	ls|grep -v "\." >/tmp/list$$
	ls z 2>/dev/null|sed "s/\$/ z/" >>/tmp/list$$
	sort -f /tmp/list$$|sed "s/\(.*\) \(.\)\$/\2\/\1/" >/tmp/slist$$
	;;
*)	echo $* >/tmp/slist$$
	;;
esac
if test ! -s /tmp/slist$$
then 
	echo "No documentation found in directory $where"
	rm /tmp/slist$$
	exit 1
fi
case $mod in
-*t*)	: troff
	sed -f $C/detail.sed `cat /tmp/slist$$`|troff $header $C/help.tr - 2>/dev/null >$HOME/detail.out
	echo "Troff output $HOME/detail.out should be sent to typesetter."
	rm /tmp/slist$$
	;;
-*o*)	: offline printing
	sed -f $C/detail.sed `cat /tmp/slist$$`|nroff $header $C/help.tr - 2>/dev/null|lpr 
	echo "Printed output sent to lpr"
	rm /tmp/slist$$
	;;
-*q*)	echo "List of documentation files in /tmp/slist$$"
	;;
*)	sed -f $C/detail.sed `cat /tmp/slist$$`|nroff $header $C/help.tr - 2>/dev/null
	rm /tmp/slist$$
	;;
esac
