X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/51e598739b071778dd3f0eee3db5c50164346da1..64e8827c5d5def0325ab7181fe939623c77e807c:/uip/mhmail diff --git a/uip/mhmail b/uip/mhmail index 2fbedccb..a0baf2e9 100755 --- a/uip/mhmail +++ b/uip/mhmail @@ -50,6 +50,10 @@ finddir() { bindir=`finddir $0` nmhbindir=`cd "$bindir" && pwd` +case `printf 'OK\n' | tail -n 1 2>&1` in + OK) tail='tail -n ' ;; + *) tail='tail -' ;; +esac #### Checks for missing mandatory arguments. @@ -80,8 +84,7 @@ fi tolist= ## To: addresses toarg=0 ## whether currently handling -to attacharg=0 ## whether currently handling -attach -attach_send_switch_added=0 ## whether added "-attach Nmh-Attachment" switch -attachind=Nmh-Attachment ## attachment indicator +attachind=Attach ## attachment indicator body= ## contents of the message body bodyarg=0 ## whether currently handling -body cclist= ## Cc: addresses @@ -110,11 +113,7 @@ for arg in "$@"; do mhmailswitch=1 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 $attachind" - attach_send_switch_added=1 - fi ;; + ;; -b|-bo|-bod|-body) mhmailswitch=1; bodyarg=1 ;; -c|-cc) mhmailswitch=1; ccarg=1 ;; -f|-fr|-fro|-from) mhmailswitch=1; fromarg=1 ;; @@ -160,7 +159,8 @@ for arg in "$@"; do #### It's not strictly necessary to have one space after #### the : that separates the header field name from the #### body, but do it to avoid surprising someone. - add=`printf %s "$arg" | sed -e 's/:/: /' -e 's/: /: /'` + #### Solaris sed wants the trailing newline in its input. + add=`printf '%s\n' "$arg" | sed -e 's/:/: /' -e 's/: /: /'` headerfieldlist="${headerfieldlist:+$headerfieldlist}$add " headerfieldarg=0 @@ -255,12 +255,12 @@ if [ "$body"x = x ]; then fi #### Add trailing newline to body if it doesn't have one. - if [ `tail -n 1 "$message_file" | wc -l` -ne 1 ]; then + if [ `${tail}1 "$message_file" | wc -l` -ne 1 ]; then printf '\n' >>"$message_file" || exit 2 fi else #### Add trailing newline to body if it doesn't have one. - [ `printf %s "$body" | tail -n 1 | wc -l` -ne 1 ] && body="$body + [ `printf %s "$body" | ${tail}1 | wc -l` -ne 1 ] && body="$body " if [ "$tmpfileresent" ]; then