[PATCH 2/4] sh-functions: add fetch_all_headers function
dedekind1 at gmail.com
Mon Feb 10 01:18:57 PST 2014
From: Jacob Keller <jacob.e.keller at intel.com>
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.
Artem: massage comments
Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
helpers/aiaiai-sh-functions | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/helpers/aiaiai-sh-functions b/helpers/aiaiai-sh-functions
index 15fb5db..8d15570 100644
@@ -81,7 +81,7 @@ compile_helpers()
-# Fetch the first occurrence of an mbox header from a file
+# Fetch the first occurrence of header "$1" from the mbox file
# Usage: fetch_header <header_name> < <mbox_file>
@@ -93,6 +93,19 @@ fetch_header()
formail -z -c -x "$hdr:" | head -n1 | aiaiai-decode-rfc-2047
+# Fetch all occurrences of header "$1" from the first e-mail in the mbox file
+# Usage: fetch_header <header_name> < <mbox_file>
+ local hdr="$1"
+ program_required "formail" ""
+ # Take every occurrence of the header. 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
More information about the aiaiai