]> diplodocus.org Git - nmh/commitdiff
Replaced mhmail -debug switch with -nosend, and added -send.
authorDavid Levine <levinedl@acm.org>
Sun, 17 Jun 2012 20:25:28 +0000 (15:25 -0500)
committerDavid Levine <levinedl@acm.org>
Sun, 17 Jun 2012 20:25:28 +0000 (15:25 -0500)
docs/pending-release-notes
man/mhmail.man
test/post/test-mhmail
uip/mhmail

index f12b408d63ba6dbd4aad44824df6b88a5e03f43a..f153a779e4fa2a8aba5f5743b3d71fca17240a2a 100644 (file)
@@ -8,7 +8,8 @@ NEW FEATURES
   same component.  In previous versions, all but the first were
   silently ignored.
 - mhmail now supports all post(8) options, and optionally can use
   same component.  In previous versions, all but the first were
   silently ignored.
 - mhmail now supports all post(8) options, and optionally can use
-  send(1) with all of its options.
+  send(1) with all of its options.  Its formerly undocumented -resent
+  switch has been documented.  And it has new -send/-nosend switches.
 
 ----------------------------
 OBSOLETE/DEPRECATED FEATURES
 
 ----------------------------
 OBSOLETE/DEPRECATED FEATURES
index cf8e73a00b56509cba55efced2b0517584d5ae76..6bbd8ae93eb7ecc877a68b662db9c84485e9ebdc 100644 (file)
@@ -27,9 +27,9 @@ mhmail \- send or read mail
 [switches\ for
 .I send
 \&...]]
 [switches\ for
 .I send
 \&...]]
+.RB [ \-send " | " \-nosend ]
 .RB [ \-version ]
 .RB [ \-help ]
 .RB [ \-version ]
 .RB [ \-help ]
-.RB [ \-debug ]
 .ad
 .SH DESCRIPTION
 .B mhmail
 .ad
 .SH DESCRIPTION
 .B mhmail
@@ -127,10 +127,14 @@ instead of
 to send the message.  This allows use of the user's context and aliases.
 .PP
 The
 to send the message.  This allows use of the user's context and aliases.
 .PP
 The
-.B \-debug
-option shows the draft file that would be posted/sent and the command
-that would be used to post/send the draft, but does not post or send
-it.
+.B \-nosend
+option shows the draft file that would be posted/sent on the command's
+standard output but does not post or send it.
+.B \-send
+provides the default behavior of posting or sending the message.  It
+can be used to disable
+.BR \-nosend ,
+for example, when using a shell alias.
 .PP
 All other switches are passed on to
 .B post
 .PP
 All other switches are passed on to
 .B post
@@ -155,7 +159,7 @@ is used.
 dist(1), inc(1), post(8), send(1)
 
 .SH DEFAULTS
 dist(1), inc(1), post(8), send(1)
 
 .SH DEFAULTS
-None
+.RB ` \-send '
 
 .SH CONTEXT
 If
 
 .SH CONTEXT
 If
@@ -167,3 +171,8 @@ context changes occur.  With the
 switch, the context of
 .B send
 is used.
 switch, the context of
 .B send
 is used.
+
+.SH BUGS
+.B \-resent
+cannot be used with
+.BR \-profile .
index 17c950541540c0f47461923a4a6ba68199b7a34c..ce4d9c6bd1b59afd4f4a6c5f1d79458084f84f4c 100755 (executable)
@@ -77,12 +77,13 @@ Usage: mhmail [addrs ... [switches]]
   -b(ody) text
   -c(c) addrs ...
   -f(rom) addr
   -b(ody) text
   -c(c) addrs ...
   -f(rom) addr
-  -s(ubject) text
+  -su(bject) text
   -r(esent)
   -pr(ofile)
   -r(esent)
   -pr(ofile)
+  -se(nd)
+  -nose(nd)
   -v(ersion)
   -h(elp)
   -v(ersion)
   -h(elp)
-  -d(ebug)
   and all post(8)/send(1) switches
 EOF
 
   and all post(8)/send(1) switches
 EOF
 
@@ -111,20 +112,18 @@ case `mhmail` in
 esac
 
 
 esac
 
 
-# check -debug
+# check -nosend
 # Not supported by compiled mhmail.
 # Not supported by compiled mhmail.
-mhmail -debug recipient@example.com -from sender@localhost \
+mhmail -nosend recipient@example.com -from sender@localhost \
   -server 127.0.0.1 -port $localport -body '' >"$actual" 2>"$actual_err"
 
 tmpfil=`head -1 $actual | sed -e 's/://'`
 
 cat > "$expected" <<EOF
   -server 127.0.0.1 -port $localport -body '' >"$actual" 2>"$actual_err"
 
 tmpfil=`head -1 $actual | sed -e 's/://'`
 
 cat > "$expected" <<EOF
-${tmpfil}:
 To: recipient@example.com
 From: sender@localhost
 
 
 To: recipient@example.com
 From: sender@localhost
 
 
-$MH_INST_DIR$auxexecdir/post ${tmpfil} -server 127.0.0.1 -port $localport
 EOF
 
 cat > "$expected_err" <<EOF
 EOF
 
 cat > "$expected_err" <<EOF
@@ -135,6 +134,26 @@ check "$expected_err" "$actual_err"
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
+# check -send
+# Not supported by compiled mhmail.
+cat > "$expected" <<EOF
+EHLO nosuchhost.example.com
+MAIL FROM:<sender@localhost>
+RCPT TO:<recipient@example.com>
+DATA
+To: recipient@example.com
+From: sender@localhost
+Date:
+
+message
+.
+QUIT
+EOF
+
+test_mhmail "$expected" "-from sender@localhost -nosend -send" '|' message
+[ ${failed:-0} -eq 0 ] || exit ${failed:-0}
+
+
 # check -from
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 # check -from
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
index 30fbbb7a3dcd969ff8ef1b5066ab45653350aef7..3727ce0da6fb8d458e7874714da9d93bf0e13806 100755 (executable)
 #   (with -profile) options.
 # * Optionally (with -profile) obeys the users profile, including
 #   AliasFile and send entries.
 #   (with -profile) options.
 # * Optionally (with -profile) obeys the users profile, including
 #   AliasFile and send entries.
-# * Adds -debug option for debugging (sending, not incorporating new mail).
+# * Adds -nosend option, which displays the draft but does not send it.
 # * Drops support for undocumented -queue option.
 #
 # To do:
 # * fix -resent with -profile
 # * Drops support for undocumented -queue option.
 #
 # To do:
 # * fix -resent with -profile
-# * rename -debug to -nosend and add -send (and note in doc that last one takes)
+# * add -header-field name:body switch
 # * add -attach file ... switch
 
 usage='Usage: mhmail [addrs ... [switches]]
 # * add -attach file ... switch
 
 usage='Usage: mhmail [addrs ... [switches]]
@@ -27,12 +27,13 @@ usage='Usage: mhmail [addrs ... [switches]]
   -b(ody) text
   -c(c) addrs ...
   -f(rom) addr
   -b(ody) text
   -c(c) addrs ...
   -f(rom) addr
-  -s(ubject) text
+  -su(bject) text
   -r(esent)
   -pr(ofile)
   -r(esent)
   -pr(ofile)
+  -se(nd)
+  -nose(nd)
   -v(ersion)
   -h(elp)
   -v(ersion)
   -h(elp)
-  -d(ebug)
   and all post(8)/send(1) switches'
 
 bindir=`dirname $0`
   and all post(8)/send(1) switches'
 
 bindir=`dirname $0`
@@ -56,7 +57,7 @@ else
   postsendargs=
   switcharg=0
   use_send=0
   postsendargs=
   switcharg=0
   use_send=0
-  debug=
+  sendsw=1
   for arg in "$@"; do
     case "${arg}" in
       -*) switcharg=0
   for arg in "$@"; do
     case "${arg}" in
       -*) switcharg=0
@@ -67,17 +68,18 @@ else
       #### ambiguous, so no conflicts with them.  And they don't have
       #### -b, -c, or -r.  For the new switches that compiled mhmail
       #### didn't have:  let -p indicate mhmail -profile, not send
       #### ambiguous, so no conflicts with them.  And they don't have
       #### -b, -c, or -r.  For the new switches that compiled mhmail
       #### didn't have:  let -p indicate mhmail -profile, not send
-      #### -port, and let -d indicate mhmail -debug, not send -draft.
+      #### -port.  -send masks the send(1) -send switch.
       -b|-bo|-bod|-body) bodyarg=1 ;;
       -c|-cc) ccarg=1 ;;
       -b|-bo|-bod|-body) bodyarg=1 ;;
       -c|-cc) ccarg=1 ;;
-      -d|-de|-deb|-debu|-debug) debug=echo ;;
       -f|-fr|-fro|-from) fromarg=1 ;;
       -h|-he|-hel|-help) printf "%s\n" "${usage}"; exit ;;
       -f|-fr|-fro|-from) fromarg=1 ;;
       -h|-he|-hel|-help) printf "%s\n" "${usage}"; exit ;;
+      -nose|-nosen|-nosend) sendsw=0 ;;
       -p|-pr|-pro|-prof|-profi|-profil|-profile) use_send=1 ;;
       -resend) printf "mhmail: did you mean -resent instead of -resend?\n" 1>&2
          exit 1 ;;
       -r|-re|-res|-rese|-resen|-resent) resent=1 ;;
       -p|-pr|-pro|-prof|-profi|-profil|-profile) use_send=1 ;;
       -resend) printf "mhmail: did you mean -resent instead of -resend?\n" 1>&2
          exit 1 ;;
       -r|-re|-res|-rese|-resen|-resent) resent=1 ;;
-      -s|-su|-sub|-subj|-subje|-subjec|-subject) subjectarg=1 ;;
+      -se|-sen|-send) sendsw=1 ;;
+      -su|-sub|-subj|-subje|-subjec|-subject) subjectarg=1 ;;
       -v|-ve|-ver|-vers|-versi|-versio|-version)
          #### Cheat instead of using autoconf and make to fill in the version.
          "${nmhbindir}"/mhpath -v | sed 's/mhpath/mhmail/'; exit ;;
       -v|-ve|-ver|-vers|-versi|-versio|-version)
          #### Cheat instead of using autoconf and make to fill in the version.
          "${nmhbindir}"/mhpath -v | sed 's/mhpath/mhmail/'; exit ;;
@@ -141,7 +143,7 @@ else
     header="${header}
 "
   else
     header="${header}
 "
   else
-    if [ "$use_send" -eq 0 ]; then
+    if [ ${use_send} -eq 0 ]; then
       postsendargs="${postsendargs:+${postsendargs} }-dist"
     else
       mhdist=1; export mhdist
       postsendargs="${postsendargs:+${postsendargs} }-dist"
     else
       mhdist=1; export mhdist
@@ -177,24 +179,21 @@ else
     printf "%s" "${header}${body}" > "${tmpfil}" || exit 1
   fi
 
     printf "%s" "${header}${body}" > "${tmpfil}" || exit 1
   fi
 
-  if [ "${debug}" ]; then
-    printf "%s:\n" `ls -1 "${tmpfil}"`
+  if [ ${sendsw} -eq 0 ]; then
     cat "${tmpfil}"
     cat "${tmpfil}"
-  fi
-
-  if [ "$use_send" -eq 0 ]; then
-    post_or_send=`${nmhbindir}/mhparam postproc`
   else
   else
-    post_or_send="${nmhbindir}/send"
-  fi
-
-  status=$?
+    if [ ${use_send} -eq 0 ]; then
+      post_or_send=`${nmhbindir}/mhparam postproc`
+    else
+      post_or_send="${nmhbindir}/send"
+    fi
 
 
-  if $debug "${post_or_send}" "${tmpfil}" ${postsendargs}; then
-    exit ${status}
-  else
-    printf "Letter saved in dead.letter\n"
-    #### exec skips the trap set above.
-    exec mv "${tmpfil}" dead.letter
+    if "${post_or_send}" "${tmpfil}" ${postsendargs}; then
+      exit
+    else
+      printf "Letter saved in dead.letter\n"
+      #### exec skips the trap set above.
+      exec mv "${tmpfil}" dead.letter
+    fi
   fi
 fi
   fi
 fi