From bb7ea7bf006807a98235dda0302bcfa6da4345be Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 26 Jan 2014 05:19:41 -0800 Subject: [PATCH] shlib.sh: redirect mail to the configured mailer The clone.sh and update.sh scripts execute "mail -s" after sourcing shlib.sh. To redirect them to the configured mailer, simply implement a mail function that works much like Util.pm's mailer_pipe function does. --- shlib.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/shlib.sh b/shlib.sh index 79e961f..171c6f7 100644 --- a/shlib.sh +++ b/shlib.sh @@ -18,6 +18,32 @@ eval $(perl -I@basedir@ $__girocco_extrainc -M$__girocco_conf -le \ git() { "$cfg_git_bin" "$@"; } +_addrlist() { + _list= + for _addr in "$@"; do + [ -z "$_list" ] || _list="$_list, " + _list="$_list$_addr" + done + echo "$_list" +} + +mail() { + _mailer="${cfg_sendmail_bin:-/usr/sbin/sendmail}" + _subject= + if [ "$1" = "-s" ]; then + shift + _subject="$1" + shift + fi + { + echo "From: \"$cfg_name\" ($cfg_title) <$cfg_admin>" + echo "To: $(_addrlist "$@")" + [ -z "$_subject" ] || echo "Subject: $_subject" + echo "Auto-Submitted: auto-generated" + echo "" + cat + } | "$_mailer" -i "$@" +} # Supports both the bang CMD... and bang_eval CMD... functions # Called when the command fails -- 2.11.4.GIT