. functions inj() { injectfield from 'to: nobody' "$@"; } testvar() { set -e echo "Checking that inject obeys $1." export $1="$2" inj | grep -q "$3" } echo "Checking that inject inserts a from line." test -n "`inj`" echo "Checking that inject preserves an existing from line." inj "from: a@b.c" | grep -q '^ a@b\.c$' echo "Checking that inject does not add more from lines." test 1 -eq `inj "from: a@b.c" | wc -l` echo "Checking that inject will strip from lines." export NULLMAILER_FLAGS=f inj "from: a@b.c" | not grep -q '^ a@b\.c$' unset NULLMAILER_FLAGS echo "Checking that inject obeys me" rm -f $SYSCONFDIR/default* inj | grep -q "@f.q.d.n>$" echo "Checking that inject obeys config/defaulthost" echo test.org >$SYSCONFDIR/defaulthost inj | grep -q '@test.org>$' echo "Checking that inject obeys config/defaultdomain" echo test >$SYSCONFDIR/defaulthost echo domain.org >$SYSCONFDIR/defaultdomain inj | grep -q '@test.domain.org>$' echo "Checking that inject ignores config/defaultdomain for localhost" echo localhost >$SYSCONFDIR/defaulthost inj | grep -q '@localhost>$' testvar HOSTNAME test1.org '@test1.org>$' testvar MAILHOST test2.org '@test2.org>$' testvar NULLMAILER_HOST test3.org '@test3.org>$' echo "Checking that inject uses getpwnam" inj | grep -q " <`id -un`@" testvar LOGNAME name1 '