From 623a2732cfa14e679adc7f29e61cfe797870acef Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Fri, 18 Feb 2022 17:16:01 -0800 Subject: [PATCH] add support for announces that were sent to multiple mailing lists.. sed part: Submitted-by: Nick Hibma --- snapaid.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/snapaid.sh b/snapaid.sh index a29c436..b7da1bc 100755 --- a/snapaid.sh +++ b/snapaid.sh @@ -124,17 +124,21 @@ get_raw() { # get the location, it's a database lookup loc=$($WGET --max-redirect=0 --method=HEAD -S -o - -O - 'https://docs.freebsd.org/cgi/mid.cgi?'"$mid" 2>/dev/null | awk 'tolower($1) == "location:" { print $2; exit }') - # Some emails are sent to both -current and -snapshot, - # we can't handle them for now - # such as 20160529215940.GA11785@FreeBSD.org if [ x"$loc" = x"" ]; then - return 1 + # Some emails are sent to both -current and -snapshot, + # such as 20160529215940.GA11785@FreeBSD.org + # try w/ some magic sed + loc=$($WGET -O - 'https://docs.freebsd.org/cgi/mid.cgi?'"$mid" 2>/dev/null | + sed -Ee '/.*(getmsg.cgi?[^"]*).*/!d;s//\/cgi\/\1/' | head -1) fi - # if it's relative, add https + # if it's host relative, add https if [ x"$loc" != x"${loc#//}" ]; then # add https loc="https:$loc" + elif [ x"$loc" != x"${loc#/[^/]}" ]; then + # add https+host + loc="https://docs.freebsd.org$loc" fi # get the raw part