Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Sep 2014 23:17:21 -0700
From:      David Benfell <benfell@parts-unknown.org>
To:        Warren Block <wblock@wonkity.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: controlled environment for regular expressions?
Message-ID:  <20140902061721.GA90979@home.parts-unknown.org>
In-Reply-To: <alpine.BSF.2.11.1409011536560.82026@wonkity.com>
References:  <20140901204147.GA53086@home.parts-unknown.org> <alpine.BSF.2.11.1409011536560.82026@wonkity.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--/9DWx/yDrRhgMJTb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Sep 01, 2014 at 03:38:13PM -0600, Warren Block wrote:
> On Mon, 1 Sep 2014, David Benfell wrote:
>=20
> > Hi all,
> >
> > I am having a major problem with regular expression matching returning
> > different results when run from a script under cron or as a delivery
> > instruction from postfix rather than from the command line.
> >
> > I don't even know how to debug this. These are all in scripts and
> > delivery instructions that I have had working for over a decade. And
> > when I run them from the command line, they work as expected.
> >
> > The path for seeking executables should not be at issue. I use the
> > PATH variable in my crontabs and set it to the same PATH as at a
> > terminal.
> >
> > I have encountered this problem with both grep and GNU sed (gsed, from
> > the port).
> >
> > This is all stuff that worked until recently, and worked for years
> > under Linux. The only change I think I've made is to implement an IPv6
> > tunnel. I hope, really hope, I can safely say that's irrelevant.
> >
> > I use zsh, also a choice that's over a decade old, for both my command
> > line and to run scripts.
> >
> > I've never liked regular expressions. I think they are an awful
> > kludge. But unfortunately, a major part of my workflow depends on them
> > working correctly and *predictably*.
> >
> > Has anyone else encountered problems with this? How do you fix it?
>=20
> An example would be useful.  My first guess is that the regexes are=20
> working, but some invisible whitespace like carriage returns has snuck=20
> into the values.

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"'

=46rom the command line, it matches every time on this header:

Subject: Cron <benfell@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.

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.

Thanks!
--=20
David Benfell <benfell@parts-unknown.org>
See https://parts-unknown.org/node/2 if you don't understand the
attachment.

--/9DWx/yDrRhgMJTb
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCgAGBQJUBWDxAAoJEBV64x4SNmArK+UP/3IUYvDcJ/Taqz6sbNRep5OC
+1aNe2Moqke/tzNAYagUSHxtqNWEUw0g3RYI+uZuaG4Mf4nU/dUXMVN96zJ0SVAT
+9M1HUu7EV6wLnGa4klC/ddw/GLqDeIIDSV06+pDC1xb3hWPmJV73gbMDjdZjGcS
GcAiL85vRco0ztieG+GlJTbv03sh2BkQAWzUy7U8d5YbU654Qjp2kU8JMZjSSsTL
saAjZ+pwiQeJQH+18S1X5sG7JjDH8X/puKAXxTwLYy9q4KQqQWAYmRV2E3Wbct35
urRlOhwki8aTUXnkMkWAEiYQfCkdVC7bsD4qdqwp+aMnCWZ27dRLrahtw3Mt1r7O
WMrklqow1O90cur8bhAEsTRrqxw5jONMs5QuOt4QOBMuIRHnuzsgvO5TC6lBTUdD
Cfb8cft75wxlOEPlm5qhWMtKVDKn+fDq7at2LNyxeVmsiLtvY5/AS7MKY3mFmE4E
d/NGgj2+dYyyZoc6OBbtf5eLAWnkwCXstpOvawdEMzs78EjhiP2//YB+9CF/R0HG
jzXeWpxbmDSHUC/Y0UOnj8jcunap8Ld8pxb5ZVui6rf1L14tI1tuCXctItbynEf3
GqI9RahjYh1gCzfifJ2Wc44v5Zs/xpagvbgmhxCXTBV+BUxxQS6S4+nJTp3yiQZu
GQmQICgvNU6G5Y0Rkdlv
=VYkE
-----END PGP SIGNATURE-----

--/9DWx/yDrRhgMJTb--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140902061721.GA90979>