octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sed vs. gsed


From: Rik
Subject: Re: sed vs. gsed
Date: Mon, 19 Sep 2016 09:32:21 -0700

On 09/19/2016 09:00 AM, address@hidden wrote:
> Subject: > Re: SED and sed vs gsed > From: > "c." <address@hidden> > Date: > 09/19/2016 08:18 AM > To: > Mike Miller <address@hidden> > CC: > address@hidden > List-Post: > <mailto:address@hidden> > Content-Transfer-Encoding: > 7bit > Precedence: > list > MIME-Version: > 1.0 (Mac OS X Mail 7.3 \(1878.6\)) > References: > <address@hidden> > In-Reply-To: > <address@hidden> > Message-ID: > <address@hidden> > Content-Type: > text/plain; charset=us-ascii > Message: > 2 > > On 18 Sep 2016, at 19:44, Mike Miller <address@hidden> wrote: > >> > All, >> > >> > I've noticed some problems with Octave's build when the sed program >> > found by configure is *not* GNU sed (e.g. on macOS, *BSD, or Solaris >> > systems). Thanks to Carlo for repeatedly pointing this out and for >> > setting up the buildbot process which can show this repeatably. >> > >> > How portable do we care to be? Should we try to make our build work with >> > any sed program, or should we improve configure to look for and require >> > GNU sed without the user needing to set SED=gsed in the environment? >> > >> > For example we use the following syntaxes in several places, all of >> > which are not portable to non-GNU sed: >> > >> >  \+ >> >  \? >> >  \| >> > >> > We could replace 'a\+' with 'aa*'. We could replace 'a\?' with >> > 'a\{0,1\}' (exact) or 'a*' (probably close enough). I'm not aware of a >> > basic RE equivalent for alternation 'a\|b'. This happens to be the one >> > of these three that we use the most (mk-builtins.sh, mk-f77-def.sh, >> > mk-octave-config-h.sh). >> > >> > -- >> > mike > > Hi Mike, > > As you pointed out on the bug tracker discussion >    >   https://savannah.gnu.org/bugs/index.php?49126 > > the same issue is there also in relation to awk/gawk. > > I also wonder whether using only one of awk/sed would > reduce the burden of maintainance and the number of > possible sources of portability problems ... > > c.

If portability is a concern, we could also consider moving to a higher level language like Perl.  Perl can do anything grep/sed/awk can do and would introduce only a single dependency, rather than three.  Perl is also widely available and installed on many Unices by default.

But I realize that might be too big a change.  If we stay with the current system, then why not just require the GNU variants of sed and awk?  We already require GNU Make, for example.  Basically, there's a lot of scripts that I don't feel like re-writing to remove the use of GNU regexp.  Not only would this take time away from more useful Octave tasks (since our volunteer time is finite), but it would also potentially introduce new bugs in the build system which would then need to be debugged, taking yet more developer time.

If we had to, however, it seems like you could often replace alternation with two separate sed commands where the ACTION simply gets duplicated.  Given that GNU sed applies the alternation operator in a left to right manner, this just means putting the first pattern above the second pattern in the file.

s/(2\|3) bugs/the bugs/
=>
s/2 bugs/the bugs/
s/3 bugs/the bugs/

--Rik



reply via email to

[Prev in Thread] Current Thread [Next in Thread]