[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#70476: `**` GNU extension only works when ERE syntax is enabled
From: |
Dylan Brotherston |
Subject: |
bug#70476: `**` GNU extension only works when ERE syntax is enabled |
Date: |
Fri, 19 Apr 2024 17:44:03 +0000 |
$ 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#70476: `**` GNU extension only works when ERE syntax is enabled,
Dylan Brotherston <=