bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: Brokenness in sed


From: Stepan Kasal
Subject: Re: Brokenness in sed
Date: Mon, 17 Nov 2003 19:42:31 +0100
User-agent: Mutt/1.4.1i

Hello,
        thank you for your bug report.
Sorry that the answer is so late.

On Sun, Oct 26, 2003 at 04:45:44PM -0800, address@hidden wrote:
> When you join two lines into the pattern space with the 'N'
> command, an insertion should precede all the text in the
> current pattern.  It does on every UNIX box I have access to,
> except for GNU's sed program.

The GNU sed does the same, in fact.  The problem is elsewhere.

First, a tricky answer: replace the line

> cmd='/extern "C\+\+"/N

with

  cmd='/extern "C\+\+/N

and it'll start working. Too much quotes.

And now, a serious answer:  the line should be
        cmd='/extern "C++"/N

as sed uses so called basic regular expressions, and + is not a metacharacter.

The behaviour of \+ is _undefined_, says POSIX.  In old implementations, \+ is
just like +, but in sed, it has special meaning, "repeat at least once", as
the meaning of + in extended or perl regexps.

Thats why your script happened to work on some systems, but it may not work
on other POSIX compliant systems.

Hope that this explains it.
        Stepan Kasal




reply via email to

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