[PATCH 1/4] email-sh-functions: make merge addresses work on multiple line inputs
Artem Bityutskiy
dedekind1 at gmail.com
Mon Feb 10 01:18:56 PST 2014
From: Jacob Keller <jacob.e.keller at intel.com>
This minor change fixes merge_addresses so that it can be used with
multiple line inputs. Basically this lets use ues formail to get the
address from multiple headers, and correctly merge the list into a comma
seperated value.
The primary usage for this change will come in a future patch which
introduces a method for getting the address out of multiple Cc headers.
Artem: massaged the patch a little bit.
Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
---
email/aiaiai-email-sh-functions | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/email/aiaiai-email-sh-functions b/email/aiaiai-email-sh-functions
index 5474577..b36a4a7 100644
--- a/email/aiaiai-email-sh-functions
+++ b/email/aiaiai-email-sh-functions
@@ -8,6 +8,9 @@
. shell-ini-config
. shell-quote
+__br="
+"
+
if [ -z "${__included_aiaiai_email_sh_functions-}" ]; then
__included_aiaiai_email_sh_functions=1
@@ -106,7 +109,10 @@ merge_addresses()
{
local addr1="$1"; shift
local addr2="$1"; shift
- local list="$(printf "%s" "$addr1,$addr2" | LC_ALL=C tr -d "\n")"
+ local list
+
+ # We assume that the input arguments may have multiple lines
+ list="$(printf "%s" "${addr1}${__br}${addr2}" | LC_ALL=C tr "\n" ",")"
printf "%s" "$list" | LC_ALL=C sed -e "s/,,/,/g" -e "s/^,//" \
-e "s/,$//" -e "s/[[:blank:]]\+/ /g"
@@ -203,13 +209,9 @@ compose_email()
local in_reply_to="$1"; shift
if [ -n "$cc" ]; then
- # A newline characters
- local __newline="
-"
-
cc="$(LC_ALL=C; printf "%s" "$cc" | tr "," "\n" | \
sed -e "/^$/d" -e "s/^/Cc: /g")"
- cc="$__newline$cc"
+ cc="$__br$cc"
fi
cat <<EOF
--
1.8.5.2
More information about the aiaiai
mailing list