From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by dpdk.org (Postfix) with ESMTP id AC57258EB for ; Fri, 25 Nov 2016 18:02:27 +0100 (CET) Received: by mail-wm0-f54.google.com with SMTP id t79so97125107wmt.0 for ; Fri, 25 Nov 2016 09:02:27 -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=zGN/vSx0V60QrFJGfHz2x6Wc3yXEk76qHFNyouC/zzA=; b=mYcD82K1fYWYvMRcmWHRGChBL1VeLEZEdAUBVue3Ax/dsH7Fkcb8Guj36CEg1sJtkq oY2nR4ilvYVi2gYmOI94ewiDEYBoxblr1WlkZEq92OLUhMgjaxAftavou5rV+ECfDgVN NHdxSz9q84iMmSHk8/hJLJ9hQITdyjXV+8EEj9wUc5kYV6EkrBOv6HgSMKCMVrOq6biG jUQ7669KowfMwFxOkI0qapmrinaTaTP6ibWo2PpShA9/zyKGPlNLtgH31Kd82Lr60WRF tm5T/DF4Lq+UI0Xy3MuBRKyk/VDE3V74gXXZedtYK0HvmoshjHy/ejfB2P3yFIpouQoW Ulsw== 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=zGN/vSx0V60QrFJGfHz2x6Wc3yXEk76qHFNyouC/zzA=; b=AwnoeCdF1kcIFgq0t3gxsZghb5YsLSTtdWBN6uL+WFiMZsLXyMvBu86FtgnFfD0NM6 nOlbs03ckHuoY9f1H0dOHpIIp7lxaFQz0Tu4E/LiDebyLV4fS9tVXyI0D0Xov4qnJrY0 F4TuflO5CIsxO+8AEq7yzdIiiaZY94kToftHuiBLpbmgNRXHjQz9FR1GcBbRMbw0fCDx /fr0hGHEmcFHx+0W2aTKc2Cm6stUtrQOJNEC8wtG8GxUM0+JCXwp2YMWKllgPBfxezYv G2qbe/y0lhmXwv2AcqYp3r8Tr9sL/aZR1wJ7YqVPCHygU1dJ5QRJuAI3NyUgXZS139DV z4hg== X-Gm-Message-State: AKaTC024BRe1uoSZWAIvCevS7ShDHMeKbHBRTLAU0w++YfeR7jeN8w3l3VReZokM7KGtR6i6 X-Received: by 10.28.210.195 with SMTP id j186mr8414776wmg.73.1480093347063; Fri, 25 Nov 2016 09:02:27 -0800 (PST) Received: from XPS13.localdomain (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id ct7sm29707757wjc.2.2016.11.25.09.02.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 Nov 2016 09:02:26 -0800 (PST) From: Thomas Monjalon To: ci@dpdk.org Date: Fri, 25 Nov 2016 18:02:09 +0100 Message-Id: <1480093334-29957-3-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1480093334-29957-1-git-send-email-thomas.monjalon@6wind.com> References: <1480093334-29957-1-git-send-email-thomas.monjalon@6wind.com> Subject: [dpdk-ci] [PATCH 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: Fri, 25 Nov 2016 17:02:27 -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 | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 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..b6cd2df --- /dev/null +++ b/tools/parse-email.sh @@ -0,0 +1,43 @@ +#! /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" +} + +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