[PATCH 2/3] sh-functions: add fetch_all_headers function

Jacob Keller jacob.e.keller at intel.com
Fri Feb 7 13:42:28 PST 2014


This patch adds a fetch_all_headers function which is used to get every
occurrence of an mbox header, rather than just the first. In combination
with the change to merge_addresses, this can be used to grab every Cc,
and To address.

Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
---
 helpers/aiaiai-sh-functions |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/helpers/aiaiai-sh-functions b/helpers/aiaiai-sh-functions
index 15fb5db..22a5153 100644
--- a/helpers/aiaiai-sh-functions
+++ b/helpers/aiaiai-sh-functions
@@ -93,6 +93,19 @@ fetch_header()
 	formail -z -c -x "$hdr:" | head -n1 | aiaiai-decode-rfc-2047
 }
 
+# Fetch all occurrences of an mbox header from a file
+# Usage: fetch_header <header_name> < <mbox_file>
+fetch_all_headers()
+{
+	local hdr="$1"
+
+	program_required "formail" ""
+
+	# Take every occurrence of the header
+	# Note: this will only take occurrences from the first of a combined mbox.
+	formail -z -c -x "$hdr:" | aiaiai-decode-rfc-2047
+}
+
 # Similar to fetch_header, but exits with code 1 if the header hasn't been
 # found, and has a little bit different interface (the result is stored in
 # "<var>").




More information about the aiaiai mailing list