X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/bb8db313c1deea588b83a44a86e653d3cfcac9c1..dd259aa56c8f8d816bc7b295cb5ad4ea80b1a8ab:/uip/mhmail diff --git a/uip/mhmail b/uip/mhmail index 7353e9a1..916732d8 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. @@ -160,7 +164,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 @@ -210,7 +215,7 @@ fi umask 077 tmpdir="${MHTMPDIR:-${TMPDIR:-${TMP:-`$nmhbindir/mhpath +`}}}" tmpfile="$tmpdir/mhmail$$" -tmpfilebackup="\"$tmpdir\"/[,#]mhmail$$" +tmpfilebackup="'$tmpdir'/,mhmail$$ '$tmpdir'/#mhmail$$" tmpfileresent= message_file= @@ -255,12 +260,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