From 0f0af4e32a4d734209c16282b63f7cb1094e2699 Mon Sep 17 00:00:00 2001 From: David Levine Date: Sat, 20 Oct 2012 10:41:43 -0500 Subject: [PATCH] Fixed printf's in test suite. --- test/anno/test-anno | 2 +- test/common.sh.in | 6 +++--- test/dist/test-dist | 8 ++++---- test/fakesendmail | 17 +++++++++-------- test/folder/test-packf | 4 ++-- test/format/test-dp | 4 ++-- test/format/test-fmtdump | 2 +- test/format/test-mymbox | 2 +- test/inc/test-msgchk | 2 +- test/mhbuild/test-utf8-body | 2 +- test/mhmail/test-mhmail | 26 ++++++++++++++++---------- test/post/test-messageid | 8 ++++---- test/post/test-mts | 2 +- test/post/test-post-aliases | 6 +++--- test/prompter/test-prompter | 4 ++-- test/rcv/test-rcvdist | 4 ++-- test/rcv/test-rcvpack | 2 +- test/rcv/test-rcvstore | 6 +++--- test/rcv/test-rcvtty | 2 +- test/repl/test-repl | 8 ++++---- test/whatnow/test-cd | 2 +- 21 files changed, 63 insertions(+), 56 deletions(-) diff --git a/test/anno/test-anno b/test/anno/test-anno index a5a292d..4f00677 100755 --- a/test/anno/test-anno +++ b/test/anno/test-anno @@ -45,7 +45,7 @@ check "$expected" "$actual" # check -version case `anno -v` in anno\ --*) ;; - * ) printf "$0: anno -v generated unexpected output\n" >&2 + * ) printf '%s: anno -v generated unexpected output\n' "$0" >&2 failed=`expr ${failed:-0} + 1`;; esac diff --git a/test/common.sh.in b/test/common.sh.in index da526de..a81e156 100644 --- a/test/common.sh.in +++ b/test/common.sh.in @@ -63,7 +63,7 @@ findprog() D=. fi if [ -f "$D/$PROG" -a -x "$D/$PROG" ]; then - printf "$D/$PROG" + printf '%s\n' "$D/$PROG" break fi done @@ -87,12 +87,12 @@ progress_update () # this automatically rounds to nearest integer arith_eval 100 \* $PROG / $RANGE; PERC=$arith_val # note \r so next update will overwrite - printf "%3d%%\r" $PERC + printf '%3d%%\r' $PERC } progress_done () { - printf "100%%\n" + printf '100%%\n' } check_for_hard_links () { diff --git a/test/dist/test-dist b/test/dist/test-dist index 709c847..769406c 100755 --- a/test/dist/test-dist +++ b/test/dist/test-dist @@ -25,13 +25,13 @@ localmbox=`${MH_LIB_DIR}/ap -format "%(localmbox)" 0` #### Use sendmail/pipe below to override default mts. mts_fakesendmail="${MHMTSCONF}-fakesendmail" sed -e 's/^mts:.*/mts: sendmail\/pipe/' "${MHMTSCONF}" > "$mts_fakesendmail" -printf "sendmail: ${srcdir}/test/fakesendmail\n" >>"$mts_fakesendmail" +printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail" MHMTSCONF="$mts_fakesendmail" # arguments: dist switches test_dist () { - printf "send\n" | dist "$@" >/dev/null + printf 'send\n' | dist "$@" >/dev/null # fakesendmail drops the message and any cc's into this mbox. mbox="${MH_TEST_DIR}"/Mail/fakesendmail.mbox @@ -77,7 +77,7 @@ check "$expected" "$actual" # check -version case `dist -v` in dist\ --*) ;; - * ) printf "$0: dist -v generated unexpected output\n" >&2 + * ) printf '%s: dist -v generated unexpected output\n' "$0" >&2 failed=`expr ${failed:-0} + 1`;; esac @@ -178,7 +178,7 @@ until grep '^Resent:' "${MH_TEST_DIR}"/Mail/inbox/2 >/dev/null; do arith_eval $i + 1 i=$arith_val if [ $i -gt 60 ]; then - printf "$0: -annotate failed, will not wait any longer\n" + printf '%s: -annotate failed, will not wait any longer\n' "$0" break fi done diff --git a/test/fakesendmail b/test/fakesendmail index 0595a47..97f63b1 100755 --- a/test/fakesendmail +++ b/test/fakesendmail @@ -10,12 +10,12 @@ ## if [ "$MH_TEST_DIR"x = x ]; then - printf "$0 is intended for use only by the nmh test suite\n" + printf '%s is intended for use only by the nmh test suite\n' "$0" exit 1 fi #### Puts message on stdin in a drop that the test knows about. -deliver="${MH_LIB_DIR}/rcvpack ${MH_TEST_DIR}/Mail/fakesendmail.mbox" +deliver="$MH_LIB_DIR/rcvpack $MH_TEST_DIR/Mail/fakesendmail.mbox" found_dasht=0 for arg in "$@"; do @@ -27,17 +27,18 @@ if [ $found_dasht -eq 0 ]; then msg= datamode=0 - printf "220 If it can't be done in Bourne shell it's not worth doing\n" + printf '%s\n' "220 If it can't be done in Bourne shell it's not worth doing" while read line; do #### Strip off carriage returns, they confuse the pattern matching. - line=`printf "$line" | tr -d '\r'` + line=`printf %s "$line" | tr -d '\r'` case "$line" in - DATA) printf "354 do tell\n"; datamode=1 ;; - .) printf "250 done\n"; datamode=0; printf "$msg" | $deliver; msg= ;; - QUIT) printf "221 byenow\n"; break ;; + DATA) printf '354 do tell\n'; datamode=1 ;; + .) printf '250 done\n'; datamode=0; + printf %s "$msg" | $deliver; msg= ;; + QUIT) printf '221 byenow\n'; break ;; *) [ $datamode -eq 1 ] && msg="${msg}${line} -" || printf "250 OK\n" +" || printf '250 OK\n' esac done else diff --git a/test/folder/test-packf b/test/folder/test-packf index 758a2ab..3e0281f 100755 --- a/test/folder/test-packf +++ b/test/folder/test-packf @@ -37,8 +37,8 @@ check "$expected" "$actual" # check -version case `packf -v` in packf\ --*) ;; - * ) printf "$0: packf -v generated unexpected output\n" >&2 - failed=`expr ${failed:-0} + 1`;; + * ) printf '%s: packf -v generated unexpected output\n' "$0" >&2 + failed=`expr ${failed:-0} + 1`;; esac # check unknown switch diff --git a/test/format/test-dp b/test/format/test-dp index 023d579..b1a1995 100755 --- a/test/format/test-dp +++ b/test/format/test-dp @@ -42,8 +42,8 @@ check "$expected" "$actual" # check -version case `$dp -v` in dp\ --*) ;; - * ) printf "$0: dp -v generated unexpected output\n" >&2 - failed=`expr ${failed:-0} + 1`;; + * ) printf '%s: dp -v generated unexpected output\n' "$0" >&2 + failed=`expr ${failed:-0} + 1`;; esac # check unknown switch diff --git a/test/format/test-fmtdump b/test/format/test-fmtdump index 44380ba..9ea7178 100755 --- a/test/format/test-fmtdump +++ b/test/format/test-fmtdump @@ -41,7 +41,7 @@ check $expected $actual # check -version case `$fmtdump -v` in fmtdump\ --*) ;; - * ) printf "$0: fmtdump -v generated unexpected output\n" >&2 + * ) printf '%s: fmtdump -v generated unexpected output\n' "$0" >&2 failed=`expr ${failed:-0} + 1`;; esac diff --git a/test/format/test-mymbox b/test/format/test-mymbox index 2cc1bb6..040390c 100755 --- a/test/format/test-mymbox +++ b/test/format/test-mymbox @@ -44,7 +44,7 @@ run_test "echo $output" 0 "Local-mailbox overriding user@host test" # Add an Alternate-Mailbox. This caused ismymbox() to lose the # Local-Mailbox, Bug #36635: -nocc me doesn't account for # Alternate-Mailboxes. -printf "Alternate-Mailboxes: user@example.com\n" >> $MH +printf 'Alternate-Mailboxes: user@example.com\n' >> $MH run_test "echo `${MH_LIB_DIR}/ap -format '%(mymbox{text})' "${myname}"`" \ 1 "Local-Mailbox with Alternate-Mailbox test" diff --git a/test/inc/test-msgchk b/test/inc/test-msgchk index 4145230..c6850d9 100755 --- a/test/inc/test-msgchk +++ b/test/inc/test-msgchk @@ -45,7 +45,7 @@ check "$expected" "$actual" # check -version case `msgchk -v` in msgchk\ --*) ;; - * ) printf "$0: msgchk -v generated unexpected output\n" >&2 + * ) printf '%s: msgchk -v generated unexpected output\n' "$0" >&2 failed=`expr ${failed:-0} + 1`;; esac diff --git a/test/mhbuild/test-utf8-body b/test/mhbuild/test-utf8-body index 2998da4..47229de 100755 --- a/test/mhbuild/test-utf8-body +++ b/test/mhbuild/test-utf8-body @@ -21,7 +21,7 @@ testname="${MH_TEST_DIR}/$$" #### Rely on sendmail/pipe below to override default mts. mts_fakesendmail="${MHMTSCONF}-fakesendmail" cp "${MHMTSCONF}" "$mts_fakesendmail" -printf "sendmail: ${srcdir}/test/fakesendmail\n" >>"$mts_fakesendmail" +printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail" MHMTSCONF="$mts_fakesendmail" # argument: expected output diff --git a/test/mhmail/test-mhmail b/test/mhmail/test-mhmail index fdb3617..c11e193 100755 --- a/test/mhmail/test-mhmail +++ b/test/mhmail/test-mhmail @@ -18,8 +18,7 @@ fi # $1 is expected output file, provided by caller # $2 is mhmail switches, except for -body # $3 of -b signifies use -body switch, | signifies provide body on stdin -# $4 contains message body. When using stdin, can contain printf(1) format -# specifiers. +# $4 contains the message body. test_mhmail () { "${MH_OBJ_DIR}/test/fakesmtp" "$actual" $localport & @@ -30,7 +29,7 @@ test_mhmail () status=1 for i in 0 1 2 3 4 5 6 7 8 9; do if [ $3 = '|' ]; then - if printf "$4" | mhmail recipient@example.com $2 \ + if printf '%s' "$4" | mhmail recipient@example.com $2 \ -server 127.0.0.1 -port $localport; then status=0 break @@ -98,8 +97,8 @@ check $expected $actual # Verified same behavior as compiled mhmail. case `mhmail -v` in mhmail\ --*) ;; - * ) echo "$0: mhmail -v generated unexpected output" 1>&2 - failed=`expr ${failed:-0} + 1`;; + * ) printf '%s: mhmail -v generated unexpected output\n' "$0" >&2 + failed=`expr ${failed:-0} + 1`;; esac # check for missing argument to switches that require them @@ -121,7 +120,7 @@ done # That will just run inc, which we don't want to do anything, # so tell inc to just display its version. # Verified same behavior as compiled mhmail. -printf "inc: -version\n" >> $MH +printf 'inc: -version\n' >> $MH case `mhmail` in inc\ --*) ;; * ) echo "$0: mhmail generated unexpected output" 1>&2 @@ -287,7 +286,7 @@ test_mhmail "$expected" '-from sender@localhost -subject Test' '|' message # 2) use send(1) by added a send switch to the profile and # verifying that it gets used. # Not supported by compiled mhmail. -printf "send: -msgid\n" >> $MH +printf 'send: -msgid\n' >> $MH cat > "$expected" <>"$mts_fakesendmail" +printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail" MHMTSCONF="$mts_fakesendmail" # $1: -messageid switch selection @@ -77,15 +77,15 @@ test_messageid () # e.g., Message-ID: <5364-1342884222.165897@ldYM.FXwU.bBqK> id='^Message-ID: <[0-9]\{1,\}-[0-9]\{1,\}\.[0-9]\{6,6\}@[-_0-9A-Za-z]\{4,4\}\.[-_0-9A-Za-z]\{4,4\}\.[-_0-9A-Za-z]\{4,4\}' ;; - *) printf "$0: unexpected messageid: $msgid_style"; exit 1;; + *) printf '%s: unexpected messageid: %s\n' "$0" "$msgid_style"; exit 1 ;; esac if grep "$id" "$cur" >/dev/null; then : else mv "$cur" "${testname}.actual" - printf "$0: unexpected "$msgid_style" Message-ID format, \ -see ${testname}.actual\n" + printf '%s: unexpected %s Message-ID format, see %s\n' "$0" \ + "$msgid_style" "${testname}.actual" exit 1 fi diff --git a/test/post/test-mts b/test/post/test-mts index 88f68c5..8266323 100755 --- a/test/post/test-mts +++ b/test/post/test-mts @@ -47,7 +47,7 @@ test_post "${testname}.actual" "${testname}.expected" "-mts smtp" #### Rely on sendmail/smtp or sendmail/pipe below to override default mts. mts_fakesendmail="${MHMTSCONF}-fakesendmail" cp "${MHMTSCONF}" "$mts_fakesendmail" -printf "sendmail: ${srcdir}/test/fakesendmail\n" >>"$mts_fakesendmail" +printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail" MHMTSCONF="$mts_fakesendmail" # $1: -mts switch selection diff --git a/test/post/test-post-aliases b/test/post/test-post-aliases index 6030ad1..ee06f28 100755 --- a/test/post/test-post-aliases +++ b/test/post/test-post-aliases @@ -27,7 +27,7 @@ EOF #### Rely on sendmail/smtp or sendmail/pipe below to override default mts. mts_fakesendmail="${MHMTSCONF}-fakesendmail" cp "${MHMTSCONF}" "$mts_fakesendmail" -printf "sendmail: ${srcdir}/test/fakesendmail\n" >>"$mts_fakesendmail" +printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail" MHMTSCONF="$mts_fakesendmail" # $1: -mts switch selection @@ -59,14 +59,14 @@ test_alias () send -draft -alias "${MH_TEST_DIR}/Mail/aliases" -mts sendmail/pipe \ >"${testname}.actual" 2>&1 if [ $? -eq 0 ]; then - printf "$0: sendmail/pipe should have failed but didn't\n" + printf '%s: sendmail/pipe should have failed but didn'"'"'t\n' "$0" else set -e check "${testname}.actual" "$2" fi else - printf "$0: invalid -mts switch selection\n" + printf '%s: invalid -mts switch selection\n' "$0" exit 1 fi } diff --git a/test/prompter/test-prompter b/test/prompter/test-prompter index 03f2f13..69eb9dd 100755 --- a/test/prompter/test-prompter +++ b/test/prompter/test-prompter @@ -41,8 +41,8 @@ check $expected $actual # check -version case `prompter -v` in prompter\ --*) ;; - * ) printf "$0: prompter -v generated unexpected output\n" >&2 - failed=`expr ${failed:-0} + 1`;; + * ) printf '%s: prompter -v generated unexpected output\n' "$0" >&2 + failed=`expr ${failed:-0} + 1`;; esac # check unknown switch diff --git a/test/rcv/test-rcvdist b/test/rcv/test-rcvdist index e49b390..8dea84d 100755 --- a/test/rcv/test-rcvdist +++ b/test/rcv/test-rcvdist @@ -38,7 +38,7 @@ check "$expected" "$actual" # check -version case `$rcvdist -v` in rcvdist\ --*) ;; - * ) printf "$0: rcvdist -v generated unexpected output\n" >&2 + * ) printf '%s: rcvdist -v generated unexpected output\n' "$0" >&2 failed=`expr ${failed:-0} + 1`;; esac @@ -53,7 +53,7 @@ run_test "$rcvdist" \ #### Use sendmail/pipe below to override default mts. mts_fakesendmail="${MHMTSCONF}-fakesendmail" sed -e 's/^mts:.*/mts: sendmail\/pipe/' "${MHMTSCONF}" > "$mts_fakesendmail" -printf "sendmail: ${srcdir}/test/fakesendmail\n" >>"$mts_fakesendmail" +printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail" MHMTSCONF="$mts_fakesendmail" # arguments: rcvdist switches diff --git a/test/rcv/test-rcvpack b/test/rcv/test-rcvpack index 46327b4..51deed7 100755 --- a/test/rcv/test-rcvpack +++ b/test/rcv/test-rcvpack @@ -39,7 +39,7 @@ check "$expected" "$actual" # check -version case `$rcvpack -v` in rcvpack\ --*) ;; - * ) printf "$0: rcvpack -v generated unexpected output\n" >&2 + * ) printf '%s: rcvpack -v generated unexpected output\n' "$0" >&2 failed=`expr ${failed:-0} + 1`;; esac diff --git a/test/rcv/test-rcvstore b/test/rcv/test-rcvstore index 0493bc2..82d270d 100755 --- a/test/rcv/test-rcvstore +++ b/test/rcv/test-rcvstore @@ -44,8 +44,8 @@ check $expected $actual # check -version case `$rcvstore -v` in rcvstore\ --*) ;; - * ) printf "$0: rcvstore -v generated unexpected output\n" >&2 - failed=`expr ${failed:-0} + 1`;; + * ) printf '%s: rcvstore -v generated unexpected output\n' "$0" >&2 + failed=`expr ${failed:-0} + 1`;; esac # check unknown switch @@ -194,7 +194,7 @@ check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first' # check Msg-Protect profile entry msgprot=640 -printf "Msg-Protect: $msgprot\n" >>$MH +printf 'Msg-Protect: %s\n' "$msgprot" >>$MH $rcvstore <${MH_TEST_DIR}/Mail/inbox/1 >$actual 2>&1 check $expected $actual run_test "find ${MH_TEST_DIR}/Mail/inbox/11 -perm $msgprot" \ diff --git a/test/rcv/test-rcvtty b/test/rcv/test-rcvtty index 6d61de2..1d0fea8 100755 --- a/test/rcv/test-rcvtty +++ b/test/rcv/test-rcvtty @@ -43,7 +43,7 @@ check "$expected" "$actual" # check -version case `$rcvtty -v` in rcvtty\ --*) ;; - * ) printf "$0: rcvtty -v generated unexpected output\n" >&2 + * ) printf '%s: rcvtty -v generated unexpected output\n' "$0" >&2 failed=`expr ${failed:-0} + 1`;; esac diff --git a/test/repl/test-repl b/test/repl/test-repl index d9c39a1..0b5b483 100755 --- a/test/repl/test-repl +++ b/test/repl/test-repl @@ -61,8 +61,8 @@ check $expected $actual # check -version case `repl -v` in repl\ --*) ;; - * ) printf "$0: repl -v generated unexpected output\n" >&2 - failed=`expr ${failed:-0} + 1`;; + * ) printf '%s: repl -v generated unexpected output\n' "$0" >&2 + failed=`expr ${failed:-0} + 1`;; esac # check unknown switch @@ -72,7 +72,7 @@ run_test "repl -nonexistent" 'repl: -nonexistent unknown' run_test "repl" 'repl: no cur message' -printf "Local-Mailbox: mymailbox@localhost%s\n" >> $MH +printf 'Local-Mailbox: mymailbox@localhost\n' >> $MH # check -cc me cat >$expected <> $MH +printf 'Alternate-Mailboxes: user@example.com\n' >> $MH cat >$expected < "$actualerr" > "$actual" || true check "$expectederr" "$actualerr" -- 1.7.10.4