2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname $0`/../..
12 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 . "$MH_OBJ_DIR/test/common.sh"
19 # Use proper program, likely not the first one on PATH.
20 rcvdist="${MH_LIB_DIR}/rcvdist"
22 expected=$MH_TEST_DIR/$$.expected
23 actual=$MH_TEST_DIR/$$.actual
28 Usage: rcvdist [switches] [switches for postproc] address ...
35 $rcvdist -help >"$actual" 2>&1
36 check "$expected" "$actual"
41 * ) printf "$0: rcvdist -v generated unexpected output\n" >&2
42 failed=`expr ${failed:-0} + 1`;;
45 # check unknown switch
46 run_test "$rcvdist -nonexistent" \
47 'rcvdist: usage: rcvdist [switches] [switches for postproc] address ...'
49 # check with no switches
51 'rcvdist: usage: rcvdist [switches] [switches for postproc] address ...'
55 cat >"$MH_TEST_DIR/Mail/notpost" <<EOF
56 if grep '^Resent-From: ' "\$2" >/dev/null; then
57 sed 's/^Resent-From:.*/Resent-From:/' "\$2" >"$actual"
59 printf 'post: message has no Resent-From: header\n'
60 printf 'post: See default components files for examples\n'
61 printf 'post: re-format message and try again\n'
65 chmod u+x "$MH_TEST_DIR/Mail/notpost"
66 sed 's/postproc:.*/#:/' "$MH" > "${MH}-new"
67 printf "postproc: $MH_TEST_DIR/Mail/notpost\n" >>"${MH}-new"
68 mv -f "${MH}-new" "$MH"
70 #### An extra space gets inserted between each header field name
71 #### and body. That probably should be fixed.
72 cat > "$expected" <<EOF
73 From: Test1 <test1@example.com>
74 To: Some User <user@example.com>
75 Date: Fri, 29 Sep 2006 00:00:00
76 Subject: Testing message 1
78 Resent-To: recipient@example.com
80 This is message number 1
83 $rcvdist recipient@example.com < "$MH_TEST_DIR/Mail/inbox/1"
84 check "$expected" "$actual"
87 cat > "$expected" <<EOF
88 From: Test1 <test1@example.com>
89 To: Some User <user@example.com>
90 Date: Fri, 29 Sep 2006 00:00:00
91 Subject: Testing message 1
92 Resent-To: recipient@example.com
95 This is message number 1
98 cat > "$MH_TEST_DIR/Mail/rcvdistcomps" <<'EOF'
99 %(lit)%(formataddr{addresses})\
100 %<(nonnull)%(void(width))%(putaddr Resent-To:)%>
101 %(lit)%(formataddr{to})\
102 %<(nonnull)%(void(width))%(putaddr Resent-From:)\n%>
105 $rcvdist -form "$MH_TEST_DIR/Mail/rcvdistcomps" recipient@example.com < \
106 "$MH_TEST_DIR/Mail/inbox/1"
107 check "$expected" "$actual"