From owner-freebsd-questions@FreeBSD.ORG Mon Sep 1 21:38:24 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1B63DA7B for ; Mon, 1 Sep 2014 21:38:24 +0000 (UTC) Received: from wonkity.com (wonkity.com [67.158.26.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "wonkity.com", Issuer "wonkity.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id C3E08150B for ; Mon, 1 Sep 2014 21:38:23 +0000 (UTC) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.14.9/8.14.9) with ESMTP id s81LcD2v083782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 1 Sep 2014 15:38:13 -0600 (MDT) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.14.9/8.14.9/Submit) with ESMTP id s81LcDxs083779; Mon, 1 Sep 2014 15:38:13 -0600 (MDT) (envelope-from wblock@wonkity.com) Date: Mon, 1 Sep 2014 15:38:13 -0600 (MDT) From: Warren Block To: David Benfell Subject: Re: controlled environment for regular expressions? In-Reply-To: <20140901204147.GA53086@home.parts-unknown.org> Message-ID: References: <20140901204147.GA53086@home.parts-unknown.org> User-Agent: Alpine 2.11 (BSF 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (wonkity.com [127.0.0.1]); Mon, 01 Sep 2014 15:38:14 -0600 (MDT) Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Sep 2014 21:38:24 -0000 On Mon, 1 Sep 2014, David Benfell wrote: > 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? An example would be useful. My first guess is that the regexes are working, but some invisible whitespace like carriage returns has snuck into the values.