]> diplodocus.org Git - nmh/blobdiff - uip/mhmail
test: Send command's stderr down pipe; don't discard.
[nmh] / uip / mhmail
index b5a3c35e89c1fe966037b206d8f36933fd11e6df..b94886f08af1de10bc9d23962baf23117d419eeb 100755 (executable)
@@ -48,6 +48,13 @@ finddir() {
   esac
 }
 
+help() {
+  printf '%s\n' "$usage"
+  #### Print the nmh intro text.
+  ${nmhbindir}/mhparam -help | sed -n -e '/^$/,$p'
+  exit
+}
+
 #### Convenience function to allow concise code below.
 die() {
     [ $# -gt 0 ]  &&  printf '%s\n' "$1" >&2
@@ -127,7 +134,7 @@ for arg in "$@"; do
     -f|-fr|-fro|-from) mhmailswitch=1; fromarg=1 ;;
     -hea|-head|-heade|-header|-headerf|-headerfi|-headerfie|-headerfiel|\
 -headerfield) mhmailswitch=1; headerfieldarg=1 ;;
-    -hel|-help) printf '%s\n' "$usage"; exit ;;
+    -hel|-help) help ;;
     -nose|-nosen|-nosend) mhmailswitch=1; sendsw=0 ;;
     -p|-pr|-pro|-prof|-profi|-profil|-profile) mhmailswitch=1; use_send=1 ;;
     -resend) die 'mhmail: did you mean -resent instead of -resend?' ;;
@@ -228,21 +235,19 @@ if [ $resent -eq 0 ]; then
   header="$header
 "
   message_file="$tmpfile"
+elif [ $use_send -eq 0 ]; then
+  postsendargs="${postsendargs:+$postsendargs }-dist"
+  message_file="$tmpfile"
 else
-  if [ $use_send -eq 0 ]; then
-    postsendargs="${postsendargs:+$postsendargs }-dist"
-    message_file="$tmpfile"
-  else
-    #### When resending with send, tmpfile will just contain the
-    #### Resent- header fields.  "$tmpfileresent" will contain
-    #### the message that is being resent.
-    tmpfileresent=`"${nmhlibexecdir}/mkstemp" -d "$tmpdir" -p mhmail-resent`
-    [ $? -ne 0 ]  &&  die "mhmail: failed to create temporary file in $tmpdir"
-    mhdist=1; export mhdist
-    mhaltmsg=$tmpfileresent; export mhaltmsg
-    message_file="$tmpfileresent"
-    printf '' >"$message_file"  || exit 2
-  fi
+  #### When resending with send, tmpfile will just contain the
+  #### Resent- header fields.  "$tmpfileresent" will contain
+  #### the message that is being resent.
+  tmpfileresent=`"${nmhlibexecdir}/mkstemp" -d "$tmpdir" -p mhmail-resent`
+  [ $? -ne 0 ]  &&  die "mhmail: failed to create temporary file in $tmpdir"
+  mhdist=1; export mhdist
+  mhaltmsg=$tmpfileresent; export mhaltmsg
+  message_file="$tmpfileresent"
+  printf '' >"$message_file"  || exit 2
 fi
 
 trap "rm -f '$tmpfile' $tmpfilebackup ${tmpfileresent:+'$tmpfileresent'}" 0
@@ -292,12 +297,11 @@ else
     post_or_send="$nmhbindir/send"
   fi
 
-  if "$post_or_send" "$tmpfile" $postsendargs; then
+  if "$post_or_send" $postsendargs "$tmpfile"; then
     exit
-  else
-    status=$?
-    mv -f "$tmpfile" dead.letter
-    printf 'Letter saved in dead.letter\n' >&2
-    exit $status
   fi
+  status=$?
+  mv -f "$tmpfile" dead.letter
+  printf 'Letter saved in dead.letter\n' >&2
+  exit $status
 fi