Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001139 [1003.1(2013)/Issue7+TC1] Base Definitions and Headers Objection Enhancement Request 2017-05-02 14:08 2024-06-11 08:54
Reporter stephane View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Stephane Chazelas
Organization
User Reference
Section 9.3.2 BRE Ordinary Characters (and same for ERE)
Page Number 183 and below
Line Number 6044 and below
Interp Status ---
Final Accepted Text Note: 0004149
Summary 0001139: require RE \] to match ] when outside bracket expressions
Description Currently, since `]` is an ordinary character, the behaviour for

grep '\[foo\]'

is "undefined". POSIX tells us to do:

grep '\[foo]'

instead.

However, it's very common for people to write grep '\[foo\]' when they meant grep '\[foo]' and no BRE implementation that I know treats \] any different from ] there.

So I'd suggest this be engraved in the spec, that BRE \] be *required* to match a "]" when outside bracket expressions (note: I'd rather [xy\] be unspecified, favouring the more portable [xy\\] instead but that would be a separate issue).

Same applies to ERE \] and \}
Desired Action The enhancement request is not for ] (and } in EREs) to be considered as "special characters", but for \] and \} to be guaranteed to match the ] and } respectively so the common "grep '\[x\]'" becomes standard/portable. That is, prohibit implementations from implementing extensions that would treat \] and ERE \} specially (very unlikely that they would anyway given that \[ and ERE \{ are required by POSIX to match [ and {).

Changes (requested additions in {{...}})

9.3.1: a special character {{or ']'}} preceded by[...]
9.3.2: {{* the ']' character outside of bracket expressions, "\]" being required to match a ']' character}}
9.4.1: "a special character{{, ']' or '}'}} preceded by"[...]
9.4.2: ordinary character{{ except ']' and '}'}} preceded by[...]
       "\]" and "\}" shall match the ']' and '}' characters respectively.
9.5.1: add \] to QUOTED_CHAR in BREs, and \] and \} in EREs
       
Tags issue8
Attached Files

- Relationships

-  Notes
(0004149)
geoffclare (manager)
2018-10-12 10:49
edited on: 2018-10-18 15:30

Proposed changes ...

On 2016 edition page 183 line 6043 section 9.3.1 change:
A BRE ordinary character, a special character preceded by a <backslash>, or a <period> shall match a single character.
to:
When not inside a bracket expression, the following shall match a single character:
  • a BRE ordinary character
  • a BRE special character or ']' preceded by an unescaped <backslash>
  • a <period>.

On 2016 edition page 183 line 6049 section 9.3.2 change:
The interpretation of an ordinary character preceded by an unescaped <backslash> ('\\') is undefined, except for:
  • The characters ')', '(', '{', and '}'
  • The digits 1 to 9 inclusive (see [xref to 9.3.6])
  • A character inside a bracket expression
to:
When not inside a bracket expression, the interpretation of an ordinary character preceded by an unescaped <backslash> is undefined, except for:
  • The characters ')', '(', '{', and '}'
  • The digits 1 to 9 inclusive (see [xref to 9.3.6])
  • The ']' character; "\]" shall match a ']' character

On 2016 edition page 184 line 6056 section 9.3.3 change:
preceded by a <backslash>
to:
preceded by an unescaped <backslash>

On 2016 edition page 184 line 6073 section 9.3.4 change:
A <period> ('.'), when used outside a bracket expression, is ...
to:
When not inside a bracket expression, a <period> ('.') is ...

On 2016 edition page 188 line 6261 section 9.4.1 change:
An ERE ordinary character, a special character preceded by a <backslash,> or a <period> shall match a single character.
to:
When not inside a bracket expression, the following shall match a single character:
  • an ERE ordinary character
  • an ERE special character, ']', or '}' preceded by an unescaped <backslash>
  • a <period>.

On 2016 edition page 188 line 6268 section 9.4.2 change:
The interpretation of an ordinary character preceded by an unescaped <backslash> ('\\') is undefined, except in the context of a bracket expression (see [xref to 9.4.5]).
to:
When not inside a bracket expression, the interpretation of an ordinary character preceded by an unescaped <backslash> is undefined, except for the ']' and '}' characters; "\]" and "\}" shall match the ']' and '}' characters, respectively.

On 2016 edition page 189 line 6272 section 9.4.3 change:
preceded by a <backslash>
to:
preceded by an unescaped <backslash>

On 2016 edition page 189 line 6277 section 9.4.3 change:
Outside a bracket expression, a <left-parenthesis> immediately followed by a <right-parenthesis> produces undefined results.
to:
When not inside a bracket expression, an unescaped <left-parenthesis> immediately followed by a <right-parenthesis> produces undefined results.

On 2016 edition page 189 line 6281 section 9.4.3 change:
both outside a bracket expression
to:
both not inside a bracket expression

On 2016 edition page 189 line 6298 section 9.4.4 change:
A <period> ('.'), when used outside a bracket expression, is ...
to:
When not inside a bracket expression, a <period> ('.') is ...

On 2016 edition page 191 line 6364 section 9.4.9 change:
when used anywhere outside a bracket expression
to:
when used anywhere except inside a bracket expression

On 2016 edition page 191 line 6365 section 9.4.9 change:
A <circumflex> ('^') outside a bracket expression shall ...
to:
When not inside a bracket expression, a <circumflex> ('^') shall ...

On 2016 edition page 191 line 6371 section 9.4.9 change:
A <dollar-sign> ('$') outside a bracket expression shall ...
to:
When not inside a bracket expression, a <dollar-sign> ('$') shall ...

On 2016 edition page 192 line 6406 section 9.5.1 change:
In a BRE, one of the character sequences:
    \^   \.   \*   \[   \$   \\
In an ERE, one of the character sequences:
    \^   \.   \[   \$   \(   \)   \|
    \*   \+   \?   \{   \\
to:
In a BRE, one of the character sequences:
    \^   \.   \*   \[   \]   \$   \\ 
In an ERE, one of the character sequences:
    \^   \.   \[   \]   \$   \(   \)   \|
    \*   \+   \?   \{   \}   \\

On 2016 edition page 193 line 6416,6417,6418,6425 section 9.5.1 change:
Anywhere outside bracket expressions
to:
Anywhere except inside bracket expressions



- Issue History
Date Modified Username Field Change
2017-05-02 14:08 stephane New Issue
2017-05-02 14:08 stephane Name => Stephane Chazelas
2017-05-02 14:08 stephane Section => 9.3.2 BRE Ordinary Characters (and same for ERE)
2017-05-02 14:08 stephane Page Number => 183 and below
2017-05-02 14:08 stephane Line Number => 6044 and below
2018-10-12 10:49 geoffclare Note Added: 0004149
2018-10-18 15:30 geoffclare Note Edited: 0004149
2018-10-18 15:31 geoffclare Interp Status => ---
2018-10-18 15:31 geoffclare Final Accepted Text => Note: 0004149
2018-10-18 15:31 geoffclare Status New => Resolved
2018-10-18 15:31 geoffclare Resolution Open => Accepted As Marked
2018-10-18 15:31 geoffclare Tag Attached: issue8
2020-04-23 13:11 geoffclare Status Resolved => Applied
2024-06-11 08:54 agadmin Status Applied => Closed


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker