GNU bug report logs - #26409
plus (`+`) not a metacharacter with --posix option, escaped or not

Previous Next

Package: sed;

Reported by: Jordan Torbiak <torbiak <at> gmail.com>

Date: Sun, 9 Apr 2017 00:56:01 UTC

Severity: normal

Tags: fixed

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Jordan Torbiak <torbiak <at> gmail.com>
Cc: 26409 <at> debbugs.gnu.org
Subject: bug#26409: plus (`+`) not a metacharacter with --posix option, escaped or not
Date: Sun, 9 Apr 2017 13:36:37 -0400
Hello,

> On Apr 8, 2017, at 20:37, Jordan Torbiak <torbiak <at> gmail.com> wrote:
> 
> The plus character can't seem to be used as a metacharacter when both the
> `-E` and `--posix` options are given.
> [...]
> $ echo 'hi+' | sed --posix -E 's/(.+)/{\1}/'
> h{i+}

Thank you for the report.

I can confirm this is reproducible.

I think the cause is that '--posix' sets the sed variable
'posixicity=POSIXLY_BASIC' and then all regex are compiled
with the  RE_LIMITED_OPS option which disables +/?/| .

[1] regex options in sed:
    https://git.savannah.gnu.org/cgit/sed.git/tree/sed/regexp.c#n90
[2] gnulib RE_LIMITED_OPS:
    https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/regex.h#n134

regarding POSIX compliance - this sounds like it needs to be fixed,
but I'm not an export - perhaps others can chime in ?

I think a simple 'if extended_regexp_flags & REG_EXTENDED' inside
the 'switch (posixicity)' can fix this. I can send a patch a bit later.

regards,
 - assaf






This bug report was last modified 8 years and 92 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.