X-Git-Url: https://git.madduck.net/etc/mailfilter.git/blobdiff_plain/eddb5ee317cb1d447bc5d9fa74de6287f2838a59..b80111ae1c9d3a2e0d29f92034bab0f843c04ddd:/bin/resubmit diff --git a/bin/resubmit b/bin/resubmit index 01990b2..17888f9 100755 --- a/bin/resubmit +++ b/bin/resubmit @@ -2,9 +2,16 @@ set -eu PROCMAIL=$HOME/.etc/mailfilter/procmail/procmailrc +FORMAIL="/usr/bin/formail -I'X-Resubmitted: $(date -R)'" -if [ -z "$1" ]; then - cat | exec $PROCMAIL +if [ -z "${1:-}" ]; then + eval $FORMAIL | exec $PROCMAIL else - exec $PROCMAIL < "$1" + if [ ! -f "$1" ]; then + echo "E: no such file: $1" >&2 + exit 1 + fi + eval $FORMAIL < "$1" | $PROCMAIL && rm -f "$1" fi + +exit 0