#!/bin/bash
# Public domain (C) 2001 Martin Macok <martin.macok@underground.cz>

if [ "$#" != "0" -o "x$1" == "x--help" ] ; then
	echo "Usage: $0 "
	echo "Injects ifile's hint header into mail. " \
	     "Message expected on stdin, result goes to stdout."
	exit 1
fi

FTMP=${TMPDIR:-/tmp}
FMSG=`mktemp $FTMP/ifile.tmp.XXXXXX`
[ -z "$FMSG" ] && echo "ERR: cannot create tmp file!" >&2 && exit 1
trap "rm -f $FMSG" 1 2 3 4 5 6 7 8  9 10 11 12 13 14 15

HINT=$(tee "$FMSG" | ifile.test.message)

formail -i "X-Ifile-Hint: $HINT" <"$FMSG"

rm -f "$FMSG"
