controlled environment for regular expressions?
benfell at parts-unknown.org
Tue Sep 2 19:22:43 UTC 2014
On Tue, Sep 02, 2014 at 07:11:45AM -0600, Warren Block wrote:
> On Mon, 1 Sep 2014, David Benfell wrote:
> > I've been pondering how to respond to this. It's all deeply buried in
> > how I sort email, which is with my own mail delivery agent written in
> > perl.
> > The MDA provides the option to call an external program, in this case,
> > grep, and sort or not sort a message into the associated Maildir based
> > on the exit code.
> > One of these instances is where I search the email headers with:
> > /usr/bin/grep "^Subject: Cron"'
> There is an extra single quote at the end of that line.
Oops. An artifact from the configuration. I don't have the sorting
hard-coded into the MDA. It works from a configuration file. The
original idea was that I should be able to sort email based on the
from address or certain other addresses in the email headers. I do
this with simple lists in text files.
But sometimes I need to do something different--and I still don't want
to hard code that into the program. Hence, grep.
> > From the command line, it matches every time on this header:
> > Subject: Cron <benfell at home> /usr/local/bin/pycardsyncer
> > and properly sorts the message.
> > But when this MDA is called either from a cron job or with postfix's
> > delivery instruction, it now fails every time.
> To see if the problem is with cron, I'd add a test cron job that just
> manually runs the test:
> echo "Subject: Cron <benfell at home> /usr/local/bin/pycardsyncer" | /usr/bin/grep -q "^Subject: Cron" && echo "matched"
> If that works,
> it's not a problem with cron or grep, and I'd proceed to
> do that same test but piping the actual test message in another cron
This worked as well.
That suggests it's my MDA that's broken, somehow, under cron but not
from the terminal. This is very bad news. And I haven't a clue why
that might be.
> Maybe also piping it to a file to see if it is being changed
> somehow in terms of whitespace or unescaped characters.
> > I haven't modified this MDA in a while. I wrote it years ago. The last
> > change I made to the delivery script was in 2011. I've been using it
> > continuously for probably over a decade.
> I would still suspect underlying things.
> Other thoughts:
> If the MDA is Perl, why use grep?
See above. Using grep is meant to be the exceptional case. Getting the
program to allow for perl regular expressions would be an exercise I'm
just not able to take on at the moment.
Basically, maildrop and procmail are too hung up on solving problems
with regular expressions. With the wildly disparate email addresses
I'm dealing with--I receive newsletters from hundreds of news
organizations--that would rapidly become unwieldy. To make them work,
I'd have to resubscribe using the plus hack (assuming that even
I'd rather my MDA just worked as it has for over a decade.
> freebsd-questions at freebsd.org mailing list
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
David Benfell <benfell at parts-unknown.org>
See https://parts-unknown.org/node/2 if you don't understand the
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 819 bytes
Desc: not available
More information about the freebsd-questions