###############
# ezmlm-split #
###############

  prompt "ezmlm-split:          "
# set up split file
  echo "edu:1:26:l1@h1" > "${DIR}/split"
  echo "edu:27:52:l2@h2" >> "${DIR}/split"
  echo "com:::l3@h3" >> "${DIR}/split"
# most testing with -D
  echo "lindberg@ezmlm.org" | ${EZBIN}/ezmlm-split -D "$DIR" | \
	grep "$LIST@$HOST" >/dev/null || \
	fatal "failed to split correctly on domain"
  echo "lindberg@id.com" | ${EZBIN}/ezmlm-split -D "$DIR" | \
	grep 'l3' >/dev/null || \
	fatal "failed to split correctly on domain"
  echo "lindberg@id.wustl.edu" | ${EZBIN}/ezmlm-split -D "$DIR" | \
	grep 'l1' >/dev/null || \
	fatal "failed to split correctly on hash + domain"
  echo "cfl@id.wustl.edu" | ${EZBIN}/ezmlm-split -D "$DIR" | \
	grep 'l2' >/dev/null || \
	fatal "failed to split correctly on hash + domain"
# one test with delivery - redirect to local manager
# should exit 99 after redirecting
  echo ":::${LIST}@$HOST" > "${DIR}/split"
  SENDER="${MOD}@$HOST"
  DTLINE="Delivered-To: ezmlm-split@$HOST"; export DTLINE
  LOCAL="$LIST-subscribe-${SND}=$HOST"
  DEFAULT="subscribe-${SND}=$HOST"
  echo "X-num: spl1" | ${EZBIN}/ezmlm-split "$DIR" >"$ERR" 2>&1

  EC="$?"
  if [ "$EC" -eq "0" ]; then
	fatal "exited 0 after forwarding, rather than 99"
  elif [ "$EC" != "99" ]; then
	fatal "failed to process message for forwarding"
  fi
# if no match, should exit 0
  echo "___:::${LIST}@$HOST" > "${DIR}/split"
  echo "X-num: spl1" | ${EZBIN}/ezmlm-split "$DIR" >"$ERR" 2>&1 || \
	fatal "failed to exit 0 after failing to match"
  checkenv spl1 "$LIST-return-@$HOST" "$LIST-subscribe-$SND=$HOST@$HOST"
# if no split file, should exit 0
  rm "${DIR}/split"
  echo "X-num: spl2" | ${EZBIN}/ezmlm-split "$DIR" >"$ERR" 2>&1 || \
	fatal "failed to exit 0 with no split file"
  checkenv spl2 "$LIST-return-@$HOST" "$LIST-subscribe-$SND=$HOST@$HOST"

  echo "OK"
