GNU bug report logs - #70476
`**` GNU extension only works when ERE syntax is enabled

Previous Next

Package: sed;

Reported by: Dylan Brotherston <d.brotherston <at> unsw.edu.au>

Date: Fri, 19 Apr 2024 23:06:11 UTC

Severity: normal

To reply to this bug, email your comments to 70476 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-sed <at> gnu.org:
bug#70476; Package sed. (Fri, 19 Apr 2024 23:06:15 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dylan Brotherston <d.brotherston <at> unsw.edu.au>:
New bug report received and forwarded. Copy sent to bug-sed <at> gnu.org. (Fri, 19 Apr 2024 23:06:16 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dylan Brotherston <d.brotherston <at> unsw.edu.au>
To: "bug-sed <at> gnu.org" <bug-sed <at> gnu.org>
Cc: "dylanbbbrother <at> gmail.com" <dylanbbbrother <at> gmail.com>
Subject: `**` GNU extension only works when ERE syntax is enabled
Date: Fri, 19 Apr 2024 17:44:03 +0000
[Message part 1 (text/plain, inline)]
$ sed --version
sed (GNU sed) 4.9

The documentation for sed BRE syntax states:
> As a GNU extension, a postfixed regular expression can also be followed by *; for example, a** is equivalent to a*
https://www.gnu.org/software/sed/manual/sed.html#BRE-syntax
But sed reports an error when ** is used in a BRE expression

$ seq 10 20 | sed 's/1**//'
sed: -e expression #1, char 7: Invalid preceding regular expression

and only allows this syntax when ERE syntax is enabled

$ seq 10 20 | sed -E 's/1**//'
0

2
3
4
5
6
7
8
9
20

grep, which also implements this GNU extension, allows ** in BRE syntax

$ seq 10 20 | grep -o '1**'
1
11
1
1
1
1
1
1
1
1
$ seq 10 20 | grep -oE '1**'
1
11
1
1
1
1
1
1
1
1

Additionally, the documentation for the `--posix` flag states
> disable all GNU extensions.
** is specifically documented as a GNU extension, but `--posix` doesn't disable the use of **

$ seq 10 20 | sed --posix -E 's/1**//'
0

2
3
4
5
6
7
8
9
20
[Message part 2 (text/html, inline)]

This bug report was last modified 14 days ago.

Previous Next


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