# check -help
+start_test "-help"
cat >"$expected" <<EOF
Usage: mhfixmsg [+folder] [msgs] [switches]
switches are:
-help
EOF
-run_prog mhfixmsg -help >"$actual" 2>&1
+#### Skip nmh intro text.
+run_prog mhfixmsg -help | sed '/^$/,$d' >"$actual" 2>&1
check "$expected" "$actual"
# check -version
+start_test "-version"
case `mhfixmsg -version` in
mhfixmsg\ --*) ;;
*) printf '%s: mhfixmsg -version generated unexpected output\n' "$0" >&2
# check that non-MIME messages aren't modified
# check -outfile
+start_test "that non-MIME messages aren't modified, and -outfile"
run_test 'mhfixmsg first -outfile '"$actual" ''
check "`mhpath first`" "$actual" 'keep first'
# check that non-MIME messages with no bodies aren't modified
# check -outfile
+start_test "that non-MIME messages with no bodies aren't modified, and -outfile"
cat >`mhpath new` <<EOF
From: Test <test@example.com>
To: Some User <user@example.com>
# check -nofixcte
+start_test "-nofixcte"
cat >"$MH_TEST_DIR"/Mail/inbox/11 <<EOF
From: Anon
To: Mailinglist
# check -fixcte (enabled by default): fixup of erroneous C-T-E in multipart
# check -verbose
+start_test "-fixcte (enabled by default): fixup of erroneous C-T-E in multipart, and -verbose"
cat >"$expected" <<EOF
From: Anon
To: Mailinglist
# check with no options: checks backup
+start_test "with no options: checks backup"
cp "$MH_TEST_DIR"/Mail/inbox/11 "$MH_TEST_DIR"/Mail/inbox/11.original
folder last >/dev/null
run_test 'mhfixmsg' ''
# check backup with -file
+start_test "backup with -file"
cp "$MH_TEST_DIR"/Mail/inbox/11 "$MH_TEST_DIR"/Mail/inbox/11.original
folder last >/dev/null
run_test 'mhfixmsg -file '"$MH_TEST_DIR"/Mail/inbox/11 ''
# check -reformat (enabled by default): addition of text/plain part
# to solitary text/html part
-#
+start_test "-reformat (enabled by default): addition of text/plain part"
prepare_space >"$expected" <<EOF
MIME-Version: 1.0
From: sender@example.com
# check implicit -file with absolute pathname
+start_test "implicit -file with absolute pathname"
run_test "mhfixmsg `mhpath last` -outfile /dev/null" ''
# check handling of boundary string that appears in message body
-#
+start_test "handling of boundary string that appears in message body"
prepare_space >"$expected" <<EOF
MIME-Version: 1.0
From: sender@example.com
# check -nodecode
+start_test "-nodecode"
prepare_space >"$expected" <<EOF
MIME-Version: 1.0
From: sender@example.com
# check -decodetext (enabled by default)
+start_test "-decodetext (enabled by default)"
cat >"$expected" <<EOF
To: recipient@example.com
From: sender@example.com
# check -decodetext with more complicated content structure
+start_test "-decodetext with more complicated content structure"
cat >$expected <<EOF
To: recipient@example.com
From: sender@example.com
# check attempted (default, 8 bit) -decodetext of binary text
#### Generated the encoded text below with:
-#### $ printf '\xbd\xb2=\xbc\x00\n' | base64
+#### $ printf '\275\262=\274\000\n' | base64
+start_test "attempted (default, 8 bit) -decodetext of binary text"
cat >`mhpath new` <<EOF
To: recipient@example.com
From: sender@example.com
# check for successful decode of a different part with attempted -decodetext
# of binary (>998 characters) text
+start_test "for successful decode of a different part with attempted -decodetext"
cat >$expected <<EOF
To: recipient@example.com
From: sender@example.com
# check for successful decode of a different part with -decodetext of binary
# (>998 characters) text
+start_test "for successful decode of a different part with -decodetext of binary"
cat >$expected <<EOF
To: recipient@example.com
From: sender@example.com
# check -decodetext of binary (containing ASCII NUL) text
-printf "%s\xbd\xb2=\xbc\x00%s" "To: recipient@example.com
+start_test "-decodetext of binary (containing ASCII NUL) text"
+printf "%s\275\262=\274\000%s" "To: recipient@example.com
From: sender@example.com
Subject: mhfixmsg binary decode test
MIME-Version: 1.0
# check that -reformat succeeds when decode of binary text fails
+start_test "that -reformat succeeds when decode of binary text fails"
prepare_space >"$expected" <<'EOF'
MIME-Version: 1.0
Date: Thu, 11 Apr 2013 02:47:08 -0700
# check -textcharset
# Also checks preservation of attributes after one (charset) that is
# modified.
+start_test "-textcharset"
cat >"$expected" <<EOF
To: recipient@example.com
From: sender@example.com
EOF
#### Generated the encoded text below with:
-#### $ printf '\xbd\xb2=\xbc\n' | base64
+#### $ printf '\275\262=\274\n' | base64
cat >`mhpath new` <<EOF
To: recipient@example.com
From: sender@example.com
# check -nofixboundary
+start_test "-nofixboundary"
cat >"$expected" <<EOF
EOF
# check that message is not output when fed through stdin
+start_test "that message is not output when fed through stdin"
run_prog mhfixmsg -file - -verbose <`mhpath last` >"$actual" 2>"$actual.err"
check "$expected" "$actual"
if grep "mhfixmsg: $MH_TEST_DIR/Mail/.*, fix multipart boundary" \
# check fixup of erroneous boundary in multipart (-fixboundary,
# enabled by default)
# check -verbose
+start_test "fixup of erroneous boundary in multipart (-fixboundary, enabled by default)"
cat >"$expected" <<EOF
Date: Fri, 13 May 2011 08:21:12 -0500
Content-Type: multipart/alternative;
# check that message is not modified when -fixboundary fails
+start_test "that message is not modified when -fixboundary fails"
cat >`mhpath new` <<EOF
Date: Fri, 13 May 2011 08:21:12 -0500
Content-Type: multipart/alternative;
# check that text/plain part is not added to text/html in multipart/related
# when it shouldn't be
+start_test "that text/plain part is not added to text/html in multipart/related when it shouldn't be"
cat >`mhpath new` <<EOF
MIME-Version: 1.0
Date: Tue, 26 Feb 2013 18:07:20 -0600
# check that text/plain part is added to text/html in multipart/related
# when it should be
+start_test "that text/plain part is added to text/html in multipart/related when it should be"
cat >"$expected" <<EOF
MIME-Version: 1.0
Date: Tue, 26 Feb 2013 18:07:20 -0600
# check handling of rfc822 message type
+start_test "handling of rfc822 message type"
cat >"$expected" <<EOF
From: Test <test@example.com>
To: Some User <user@example.com>
# check not stripping of CRs from ASCII text context (default)
+start_test "not stripping of CRs from ASCII text context (default)"
cat >"$expected" <<EOF
MIME-Version: 1.0
From: sender@example.com
# check stripping of CRs from ASCII text context
+start_test "stripping of CRs from ASCII text context"
cat >"$expected" <<EOF
MIME-Version: 1.0
From: sender@example.com
# check -replacetextplain
+start_test "-replacetextplain"
prepare_space >"$expected" <<EOF
To: recipient@example.com
From: sender@example.com
# check -noreplacetextplain
+start_test "-noreplacetextplain"
cat >"$expected" <<EOF
To: recipient@example.com
From: sender@example.com
# check removal of extraneous trailing semicolon from header parameter list
+start_test "removal of extraneous trailing semicolon from header parameter list"
cat >"$expected" <<EOF
To: recipient@example.com
Subject: test
# check rmmproc
+start_test "rmmproc"
cat >"$MH_TEST_DIR/Mail/rmmproc" <<'EOF'
mv "$1" "$1.backup"
EOF
# check -normmproc
+start_test "-normmproc"
cp "${MH_TEST_DIR}/Mail/inbox/21" "${MH_TEST_DIR}/Mail/inbox/22"
run_test 'mhfixmsg 21 -normmproc'
# check -rmmproc
+start_test "-rmmproc"
run_test 'mhfixmsg 21 -rmmproc true'
if test -f '${MH_TEST_DIR}/Mail/inbox/22.backup'; then
echo check of mhfixmsg -rmmproc FAILED, should not have created backup file
# check -fixtype
+start_test "-fixtype"
cat >"$expected" <<EOF
To: recipient@example.com
From: sender@example.com
# check default -decodetypes
+start_test "default -decodetypes"
cat >$expected <<EOF
To: recipient@example.com
From: sender@example.com
# check -decodetypes text/plain
+start_test "-decodetypes text/plain"
cat >$expected <<EOF
To: recipient@example.com
From: sender@example.com
# check -decodetypes attachment/ics
+start_test "-decodetypes attachment/ics"
cat >$expected <<EOF
To: recipient@example.com
From: sender@example.com
# check -decodetypes attachment/ics and -nocrlflinebreaks
+start_test "-decodetypes attachment/ics and -nocrlflinebreaks"
cat >$expected <<EOF
To: recipient@example.com
From: sender@example.com
# check that input is passed through to output when there's a parse error
# (the charset string is missing its closing quote) with -outfile
+start_test "that input is passed through to output when there's a parse error"
cat >"$expected.err" <<EOF
mhfixmsg: invalid quoted-string in message 31's Content-Type: field
(parameter charset)
# (the charset string is missing its closing quote) with -outfile, and
# input from stdin. Don't check err output, because it contains the name
# of a tmp file. It's similar to that of the previous check.
+start_test "that input is passed through to output when there's a parse error"
set +e
run_prog mhfixmsg -file - -outfile - <`mhpath last` >"$actual" 2>/dev/null
set -e
check "$expected" "$actual"
-
+finish_test
exit $failed