#! /bin/sh
. /usr/lib/news/lib/innshellvars

##  $Revision: 1.12 $
##  Sendme control-message handler

PROG=sendme
. ${PATHBIN}/parsecontrol "$@"

case ${ACTION} in
mail)
    ${SM} ${ARTICLE} | sed -e 's/^~/~~/' \
	| ${MAILCMD} -s "sendme by ${FROM}" ${NEWSMASTER}
    ;;
doit)
    ##  Scan the message body.
    ${SM} ${ARTICLE} | ${SED} -e '1,/^$/d' | grephistory -s >${TEMP}
    if [ -s ${TEMP} ]; then
	## xxx Need to lock the work file?
	cat ${TEMP} >>${BATCH}/${PATHHOST}.work
    fi
    rm -f ${TEMP}
    ;;
esac

exit
