X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/3b0fc690e5b096f17cedb923471cad4a11cc23d5..54dae008ec9e75cd8625945d78cff47a88261bfa:/uip/mhmail diff --git a/uip/mhmail b/uip/mhmail index 235eebac..f5cebb6d 100755 --- a/uip/mhmail +++ b/uip/mhmail @@ -7,25 +7,23 @@ # complete copyright information. # # Emulation of compiled mhmail(1), with these differences: -# * Instead of silently not sending an empty message, notifies user -# "mhmail: empty message not sent, use -body '' to force." -# * The compiled mhmail dropped a trailing newline from the -body argument. +# * Adds -send/-nosend, -headerfield, and -attach options. # * Supports all post(8) (by default, without -profile) or send(1) # (with -profile) options. # * Optionally (with -profile) obeys the users profile, including # AliasFile and send entries. -# * Adds -send/-nosend and -header-field options. +# * Instead of silently not sending an empty message, notifies user +# "mhmail: empty message not sent, use -body '' to force." +# * The compiled mhmail dropped a trailing newline from the -body argument. # * Drops support for undocumented -queue option. -# -# To do: -# * add -attach file ... switch usage='Usage: mhmail [addrs ... [switches]] switches are: + -at(tach) file [-at(tach) file] ... -b(ody) text -c(c) addrs ... -f(rom) addr - -hea(der-field) name:field [-hea(der-field) name:field] ... + -hea(derfield) name:value [-hea(derfield) name:value] ... -su(bject) text -r(esent) -pr(ofile) @@ -44,6 +42,8 @@ if [ $# -eq 0 ]; then else #### Go through all the switches so we can build the draft. tolist= + attacharg=0 + attach_send_switch_added=0 body= bodyarg=0 cclist= @@ -69,11 +69,22 @@ 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 - #### -port. -send masks the send(1) -send switch. + #### -port. -send masks the send(1) -send switch. -attach + #### masks the send(1) -attach switch. + -at|-att|-atta|-attac|-attach) + attacharg=1; + use_send=1 + if [ ${attach_send_switch_added} -eq 0 ]; then + #### Override any send -attach switch in user's profile. + postsendargs=\ +"${postsendargs:+${postsendargs} }-attach Nmh-Attachment" + attach_send_switch_added=1 + fi + ;; -b|-bo|-bod|-body) bodyarg=1 ;; -c|-cc) ccarg=1 ;; -f|-fr|-fro|-from) fromarg=1 ;; - -hea|-head|-heade|-header|-header-|-header-f|-header-fi|-header-fie|-header-fiel|-header-field) headerfieldarg=1 ;; + -hea|-head|-heade|-header|-headerf|-headerfi|-headerfie|-headerfiel|-headerfield) headerfieldarg=1 ;; -hel|-help) printf "%s\n" "${usage}"; exit ;; -nose|-nosen|-nosend) sendsw=0 ;; -p|-pr|-pro|-prof|-profi|-profil|-profile) use_send=1 ;; @@ -99,6 +110,11 @@ else elif [ ${subjectarg} -eq 1 ]; then subject="${arg}" subjectarg=0 + elif [ ${attacharg} -eq 1 ]; then + headerfieldlist="${headerfieldlist:+${headerfieldlist}}\ +Nmh-Attachment: ${arg} +" + attacharg=0 elif [ ${headerfieldarg} -eq 1 ]; then #### It's not strictly necessary to have one space after #### the : that separates the header field name from the