#!/bin/sh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# cmdtext720 src/cmdtext/usr/bin/diction/diction.sh 1.10 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 1993,2007 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
# @(#)92        1.10  src/cmdtext/usr/bin/diction/diction.sh, cmdtext, cmdtext720 3/30/07 03:21:34
#
# COMPONENT_NAME: (CMDTEXT) Text Formatting Services
#
# FUNCTIONS:
#
# ORIGINS: 3, 27
#
# (C) COPYRIGHT International Business Machines Corp. 1998
# All Rights Reserved
# Licensed Materials - Property of IBM
#
#D=/usr/bin
#B=/usr/lib
echo "$*"

umask 077
TMPDIR=${TMPDIR:-$HOME/tmp}
[[ ! -d $TMPDIR ]] && TMPDIR=/tmp
TMPDIR=$TMPDIR/${0##*/}.$$

tmp=$TMPDIR/diction.$RANDOM

/usr/bin/mkdir $TMPDIR || {
        print -u2 "${0##*/}: Could not create temporary files"
        exit 1
}
trap "/bin/rm -rf $TMPDIR 2>/dev/null" EXIT INT TERM QUIT HUP

rest=
flag=
nflag=
mflag=-me
lflag=-ml
kflag=
file=
set -- `/usr/bin/getopt f:nkm: $* 2>/dev/null`
if [ $? != 0 ] ; then
/usr/bin/dspmsg dprog.cat 1 "Invalid flags\n"
exit 2
fi
while [ $1 != -- ]; do
case $1 in
-f) flag=-f;shift; file=$1; shift; continue;;
-n) nflag=-n;shift; continue;;
-k) kflag=-k;shift; continue;;
-m) case $2 in
	m|s|e|a) mflag=$1$2;;
# Added mflag below to force deroff to ignore MM macros.
	l) lflag=-ml; mflag=-mm;; 
	esac; shift; shift; continue;;
esac
done
shift
rest=$*
#$D/deroff $kflag $lflag $mflag $rest^$B/dprog -d $nflag $flag $file
/usr/bin/deroff $kflag $lflag $mflag $rest > $tmp
/usr/bin/cat $tmp | /usr/bin/dprog -d $nflag $flag $file
/usr/bin/rm -rf $TMPDIR