#! /bin/sh
# batchra [file...] - requested-articles batcher - read sendme message(s),
# look up history entries and get file names, append the names to batch file

# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
. ${NEWSCONFIG-/etc/news/bin/config}
PATH=$NEWSCTL/bin:$NEWSBIN/batch:$NEWSBIN:$NEWSPATH; export PATH

batchdir=`expr "$NEWSSITEDIR" : "^\(.*\)\.[^./]*$"`
case "$batchdir" in
'')	batchdir="$NEWSARTS/out.going/$NEWSSITE"	;;
esac
files="`cat $*`"

lock LOCKexplode $$ || exit 1
trap "unlock LOCKexplode ; trap 0 ; exit 0" 0 1 2 15

for f in $files
do
	if test -r $f	# ignore control files that have vanished
	then
		sed '1,/^$/d' $f
	fi
done | egrep '^<' | dbz -x $NEWSCTL/history |
	awk '{ print $NF }' | tr . / >>$batchdir/togo
