www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/03/02:30:07

Date: Thu, 3 Sep 1998 09:29:43 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "Peter J. Farley III" <pjfarley AT banet DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: BUG REPORT: sed v3.02
In-Reply-To: <35ed8493.1668599@news1.banet.net>
Message-ID: <Pine.SUN.3.91.980903092836.6220A-100000@is>
MIME-Version: 1.0

On Wed, 2 Sep 1998, Peter J. Farley III wrote:

> I have found a small bug in sed v3.02.  The following sed script works
> with sed v1.18, but fails with v3.02.  The purpose of the script is to
> put a '-' in front of any makefile command line which starts with
> '$(RMF)' and doesn't already have a '-' in front.
> 
> Script:
> ---------- tmp2.sed ---------------
> s/^\([ 	]\+\)\($(RMF)\)/\1-\2/
> ---------- tmp2.sed ---------------
>        ^  <-- Note: There is a real tab character here!

It's not a bug in Sed, it's a bug in your script.  It uses the \+
meta-character that isn't supported by the basic regular expressions
employed by Sed.  (The library reference page of the function
`regcomp' in libc.inf explains near the end the differences between
the basic and the extended regular expressions; read it carefully.)

The reason why sed 1.18 works in this case is that Sed 1.18 was built
with the GNU regexp library which is very lenient in enforcing strict
Posix regexp specifications; it also supports many extensions of Posix
regexps by default.  If you try running your script with gsed.exe
(which was also built with GNU regexp library), you will see that your
script works in Sed 3.02 as well.

Here's how your script should look like to work with all versions of
Sed:

  s/^\([ 	][ 	]*\)\($(RMF)\)/\1-\2/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019