From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by dpdk.org (Postfix) with ESMTP id C5A3758C8 for ; Thu, 1 Dec 2016 14:45:03 +0100 (CET) Received: by mail-wm0-f47.google.com with SMTP id f82so248891394wmf.1 for ; Thu, 01 Dec 2016 05:45:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=yYnDlJLd/nOojNZJ5SJT3vguDqendcxrk+Y6J9kJ7a4=; b=jBLcMqH0rou5Ie0o3ykK9xhb7Vm+mHrCXApbPMm7hFxZ/ABQ+HGri7rNiW/au7RWAy 2FWHy5qtz6IYhtsym89tqfFVE/DdDauIoRPtws6TqJmRa+HSaxIxwGqfizJkogpk0HEw q6/9m8+H1PPTfDOJifcYBWjm+h8mI9xa6WX8QbXEi3gH3nbwDu2jGHW5znzxbbUrnGkc Pgrac8n6Pn8we+l7kqvmXVb3tRaLzvd/VEzQawOqS5UweVFLWNTCRClQMMagqVYGipP+ C2G6JZBtGg5djl4f4V3MD3ifQZEzoqnG8P+26VzHtXZi0HRCbjVlp0BIP3NQHIGq5THV BA8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=yYnDlJLd/nOojNZJ5SJT3vguDqendcxrk+Y6J9kJ7a4=; b=F1rSmn54l064CgkIRK0Vn3e7OQTt4qp9cWUHXBGEXLxSP8BZMLUw293UWL6r/1o4ab 2+I5IJvu+Fd7lhzKpb8u5CuNnyN/570dzP9WSjjciJ/zGSEaAqlX8Ukh/VmOfcfj9Nkk 6GFBaMjPei0sI3dEoYT4lkZX7OSh/dwYrxrpINRWSEGvMYD/wq7VjAiRtxImJq5UCBkg JtorfQB4YbLfttS5hjR6nC8YdylwzQwQ8foM4cDqro3lRRbRqWqK+IKX9s54pFgwerPZ EDG1W7oOHXs/h4SctLf5koGqOFCHezAD2GUp6yOI57UkfJR2DGdHoO192a2Ymzju+7Vn wnDQ== X-Gm-Message-State: AKaTC027SM24WKnvt1rM1RpLVg1DoJDkIRvxGWak7+5uCDPlawXmo46cNnJ4dsj/2HvMnbgy X-Received: by 10.28.69.17 with SMTP id s17mr34349461wma.141.1480599903326; Thu, 01 Dec 2016 05:45:03 -0800 (PST) Received: from XPS13.localdomain (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id c202sm15808333wme.1.2016.12.01.05.45.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Dec 2016 05:45:02 -0800 (PST) From: Thomas Monjalon To: ci@dpdk.org Date: Thu, 1 Dec 2016 14:44:47 +0100 Message-Id: <1480599892-14190-3-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1480599892-14190-1-git-send-email-thomas.monjalon@6wind.com> References: <1480093334-29957-1-git-send-email-thomas.monjalon@6wind.com> <1480599892-14190-1-git-send-email-thomas.monjalon@6wind.com> Subject: [dpdk-ci] [PATCH v2 2/7] tools: add mail parser X-BeenThere: ci@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: CI discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Dec 2016 13:45:03 -0000 This script get some mail headers from an email file. The retrieved headers can be used for test and report in other scripts. Signed-off-by: Thomas Monjalon --- tools/parse-email.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 tools/parse-email.sh diff --git a/tools/parse-email.sh b/tools/parse-email.sh new file mode 100755 index 0000000..2292773 --- /dev/null +++ b/tools/parse-email.sh @@ -0,0 +1,44 @@ +#! /bin/sh -e + +# This file is in the public domain. + +print_usage () { + cat <<- END_OF_HELP + usage: $(basename $0) + + Parse basic headers of the email + and print them as shell variable assignments to evaluate. + END_OF_HELP +} + +while getopts h arg ; do + case $arg in + h ) print_usage ; exit 0 ;; + ? ) print_usage >&2 ; exit 1 ;; + esac +done +shift $(($OPTIND - 1)) +if [ -z "$1" ] ; then + printf 'file argument is missing\n\n' >&2 + print_usage >&2 + exit 1 +fi + +getheader () # +{ + sed "/^$1: */!d;s///;N;s,\n[[:space:]]\+, ,;s,\n.*,,;q" "$2" | + sed 's,",\\",g' +} + +subject=$(getheader Subject "$1") +from=$(getheader From "$1") +msgid=$(getheader Message-Id "$1") +[ -n "$msgid" ] || msgid=$(getheader Message-ID "$1") +listid=$(getheader List-Id "$1") + +cat <<- END_OF_HEADERS + subject="$subject" + from="$from" + msgid="$msgid" + listid="$listid" +END_OF_HEADERS -- 2.7.0