[PATCH 2/3] sh-functions: add fetch_all_headers function
Jacob Keller
jacob.e.keller at intel.com
Tue Feb 11 09:50:33 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.
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>
---
0 files changed
diff --git a/helpers/aiaiai-sh-functions b/helpers/aiaiai-sh-functions
index 15fb5db..8d15570 100644
--- a/helpers/aiaiai-sh-functions
+++ b/helpers/aiaiai-sh-functions
@@ -81,7 +81,7 @@ compile_helpers()
done
}
-# 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>
fetch_header()
{
@@ -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>
+fetch_all_headers()
+{
+ 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
# "<var>").
More information about the aiaiai
mailing list