Skip to content

--posix should disable the GNU regular expression escapes (\? \+ \| \w \s) #542

Closed

Description

@sylvestre

Found by the differential fuzzer (fuzz/fuzz_targets/fuzz_sed.rs).

With --posix, GNU sed drops the GNU regular expression escapes: \?, \+,
\| are not operators and \w, \s are not classes, they all stand for the
plain character. We keep honoring them.

$ printf 'a\nb\n0?\n' | sed --posix -e '/a\+/d'
a
b
0?
$ printf 'a\nb\n0?\n' | ./target/release/sed --posix -e '/a\+/d'
b
0?

Same for the others:

script GNU --posix deletes we delete
/0\?/d 0? every line (empty match)
/a\+/d nothing a
/a|b/d nothing a and b
/\w/d nothing every line

Until this is fixed the fuzzer skips these scenarios; see KNOWN_ISSUES in
fuzz/fuzz_targets/fuzz_sed.rs.

Activity

  1. e-kwsm commented on Oct 18, 2026

    @e-kwsm
    Contributor

    #288

    From POSIX BRE:

    The '?', '+', and '|' characters; it is implementation-defined whether "?", "+", and "|" each match the literal character '?', '+', or '|', respectively, or behave as described for the ERE special characters '?', '+', and '|', respectively (see 9.4.3 ERE Special Characters).

    Note:
    A future version of this standard may require "\?", "\+", and "\|" to behave as described for the ERE special characters '?', '+', and '|', respectively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions