chiark / gitweb /
Substitute the message number for [REFERENCE] in added-headers, if present
[modbot-mtm.git] / stump / bin / processApproved
index 9cdf3c6cead81535f081f2449edd3ceb27112abb..a62333ecd60c78160bccb07f5c239c2ebe745ee3 100755 (executable)
@@ -1,4 +1,7 @@
-#!/bin/sh
+#!/bin/bash
+
+set -ex
+set -o pipefail
 
 NEWSBIN=/var/lib/newsbin; export NEWSBIN
 shift
@@ -28,7 +31,12 @@ post() {
   (
     echo Path: "$PATH_SUFFIX"
 
-    cat $MNG_ROOT/etc/added-headers | grep ': ' 
+    perl <$MNG_ROOT/etc/added-headers -ne '
+        next unless m/\:/;
+        s/\[REFERENCE\]/[$ENV{"WEBSTUMP_MESSAGENUM"}]/g
+            if defined $ENV{"WEBSTUMP_MESSAGENUM"};
+        print or die $!;
+    '
     # I do grep above because a lot of users inserts empty
     # lines in the added headers.