Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 704:599fddb2370d
bsmtp2dma: Some modernizations: use "read -r" and enhance some quoting
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 02 Oct 2024 12:43:14 +0200 |
| parents | 7126823e4d70 |
| children | 7cb17eaac812 |
| files | sbin/bsmtp2dma |
| diffstat | 1 files changed, 10 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/sbin/bsmtp2dma Tue Oct 01 20:18:12 2024 +0200 +++ b/sbin/bsmtp2dma Wed Oct 02 12:43:14 2024 +0200 @@ -54,9 +54,9 @@ # # Configuration directory # -: ${CONFIGDIR:=@@ETCDIR@@} +: ${CONFIGDIR:="@@ETCDIR@@"} -test -r "${CONFIGDIR}/bsmtp2dma.conf" && . "${CONFIGDIR}/bsmtp2dma.conf" +[ -r "${CONFIGDIR}/bsmtp2dma.conf" ] && . "${CONFIGDIR}/bsmtp2dma.conf" # @@ -176,7 +176,7 @@ # Start the mailer **before** opening the pipe; otherwise a # deadlock occurs # - "$MAILER" -f "${_sender_addr}" "${_recipient_addr}" <${MAILFIFO_STDIN} >${MAILFIFO_STDOUT} & + "$MAILER" -f "${_sender_addr}" "${_recipient_addr}" <"${MAILFIFO_STDIN}" >"${MAILFIFO_STDOUT}" & _pid_mailer=$! exec 3>"${MAILFIFO_STDIN}" @@ -208,12 +208,10 @@ # preserve leading white space when reading with `read` _oifs="$IFS" - IFS=" -" - cat "${MAILCONTENT}" | - while read _text; do - printf "%s\n" "$_text" >&3 - done + IFS=$'\n' + while read -r _text; do + printf "%s\n" "$_text" >&3 + done <"${MAILCONTENT}" # not all mailer recognize this # printf ".\n" >&3 IFS="$_oifs" @@ -221,7 +219,7 @@ # close the fd to the pipe: coproc should get EOF and terminate exec 3>&- # read eventually remaining stuff from the mailer until EOF - IFS='' read _dummy <&4 + IFS='' read -r _dummy <&4 exec 4<&- wait $_pid_mailer @@ -311,9 +309,8 @@ exec 3>"${MAILCONTENT}" # preserve leading white space when reading with `read` _oifs="$IFS" -IFS=" -" -while read _text; do +IFS=$'\n' +while read -r _text; do if [ "${_text}" = "." ]; then break else
