[PATCH] aiaiai-email-lda: use the References mail header
dedekind1 at gmail.com
Thu Nov 6 23:41:49 PST 2014
On Thu, 2014-11-06 at 19:50 +0100, Robert Jarzmik wrote:
> Aiaiai local mail delivery agent should be able to cope with forwarded
> mails, not only git-send-email.
> One popular method of forwarding a mail thread is to have it embedded in
> a single mulitpart mail in rfc822 format. But this transformation
> changes the In-Reply-To: headers into References: headers.
> The goal of this patch is to teach aiaiai LDA to understand both
> In-Reply-To and References in its mail handling. This enables mail
> Signed-off-by: Robert Jarzmik <robert.jarzmik at free.fr>
> doc/README | 22 ++++++++++++++++++++++
> email/aiaiai-email-lda | 13 ++++++++-----
> 2 files changed, 30 insertions(+), 5 deletions(-)
> diff --git a/doc/README b/doc/README
> index 0e699a2..0e6571c 100644
> --- a/doc/README
> +++ b/doc/README
> @@ -102,6 +102,28 @@ The 'aiaiai-test-patchset' script does all the testing work and outputs the
> test results to stdout. 'aiaiai-email-test-patchset' captures the output and
> sends it back to the patch submitter.
> +A more complicated mail setup dealing with forwards and multi-part emails
> +would be :
> +$ cat /home/aiaiai/bin/my-aiaiai-lda
> + #!/bin/sh
> + formail_opt=""
Thanks. But would you please quote variables. This is the convention we
follow in this set of scripts, for our on good.
> + mail=$(mktemp)
> + cat > $mail
> + to="$(formail -c -z -x "To:" < $mail)"
> + [ -n "$to" ] && formail_opt="$formail_opt -I \"To: $to\""
> + project="$(formail -c -z -x "X-Aiaiai-Project:" < $mail)"
> + [ -n "$project" ] && formail_opt="$formail_opt -I \"X-Aiaiai-Project: $project\""
> + commit="$(formail -c -z -x "X-Aiaiai-Commit:" < $mail)"
> + [ -n "$commit" ] && formail_opt="$formail_opt -I \"X-Aiaiai-Commit: $commit\""
> + cat "$mail" | eval formail $formail_opt -d -s $HOME/git/email/aiaiai-email-lda \
> + -v --reap-archive=43200 --reap-incomplete=10 -- $HOME/aiaiai-workdir \
> + >> $HOME/aiaiai-logs/email-lda.log" 2>&1
The last quote has no beginning?
How about this:
cat "$mail" | eval formail "$(formail_opt -d -s
"$HOME/git/email/aiaiai-email-lda" v --reap-archive=43200
--reap-incomplete=10 -- "$HOME/aiaiai-workdir")" >>
Yes, this is sound a bit of "too much". But the thing is that shell is a
very weird language, and big shell scripts are usually completely
unreadable and unmaintainable.
Today I'd choose python to write this stuff. Bat back to that time I did
not know python :-)
Anyway, aiaiai is has a lot of shell code. To make it more readable,
robust, and maintainable, we try to follow strict rules. One of them -
always quote variables.
Unquoted variables are dangerous - if it has a white-space, the program
falls apart. Also, if it is empty, it has different semantics comparing
to a quoted one (nothing vs empty line).
So we quote everything. Except the cases where we deliberately don't do
this. Like: program $verbose
We know that verbose is either -v or nothing. So "program" will either
be called with -v or no argument. If we quoted it, then instead of no
argument, the program would be called with an empty argument, which is a
In your case, you call mktemp. You can rely on the fact that it will
return a shell-friendly name, yes. But I ask to quote just for the
More information about the aiaiai