5 messages in net.sourceforge.lists.courier-maildropRe: [maildropl] Req for help adding h...
FromSent OnAttachments
Doc WalkerFeb 7, 2005 7:56 pm 
denis moellerFeb 8, 2005 12:28 am 
Sam VarshavchikFeb 8, 2005 4:19 am 
Doc WalkerFeb 9, 2005 10:52 am 
Sam VarshavchikFeb 9, 2005 4:07 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [maildropl] Req for help adding header with $MATCH pattern containing single quoteActions...
From:Sam Varshavchik (mrs@courier-mta.com)
Date:Feb 8, 2005 4:19:51 am
List:net.sourceforge.lists.courier-maildrop

Doc Walker writes:

The following is one of the criteria in my .mailfilter:

# File Courier-Maildrop mailing list messages: if (/^List-ID:.*courier-maildrop/) { xfilter "${REFORMAIL} -A 'X-WVFans-Mailfilter: 0x0301'" MATCH=escape(${MATCH}) xfilter "${REFORMAIL} -A 'X-WVFans-Match: ${MATCH}'" to "$DEFAULT/.Doc.WVFans_net.Courier-Maildrop.Inbox" }

I add a header to mail delivered with Maildrop indicating which rule was used to move the file, in this case #0x0301, as well as the regular expression that satisfied the criteria. I'm running into an error with the mail received from the Maildrop mailing list because the $MATCH expression contains a single apostrophe (') in the regular expression. I get the following error in my mail.log:

unexpected EOF while looking for matching `''

It appears that $MATCH is replaced with the actual expression as the .mailfilter is parsed and the single quote is not matched, giving the above error.

How do I work around this? I've tried various combinations of quotes, braces, and brackets, but with no success. I realize that I can change my regexp criteria, knowing that the single quote will cause my header addition to fail, but I would like to learn more how I can safely add text headers to an email message. I believe this is one of the purposes of the escape() function.

Try this:

Get rid of escape(). Change the command to:

xfilter '$REFORMAIL -A "X-WVFans-Match: $MATCH"'

All maildrop variables are exported in the environment. The above string gets evaluated by maildrop as:

No variable substitution occurs inside apostrophes. The above string is passed verbatim to the shell, to execute.

All maildrop variables are now in the environment, and the shell will perform variable expansion.