Skip to content

--posix -e 'a\bar' causes an error #144

Closed

Description

@cakebaker

Another issue found with the fuzzer:

$ printf "foo" | cargo run -q sed --posix -e 'a\bar'
sed: <script argument 1>:1:3: error: extra characters after \ at the end of `a' command
$ printf "foo" | sed --posix -e 'a\bar'
foo
bar

Activity

  1. e-kwsm commented on Jan 18, 2026

    @e-kwsm
    Contributor

    a\bar is not specified in POSIX; it is a GNU extension. BSD rejects it:

    sed: 1: "a\bar
    ": extra characters after \ at the end of a command
    
  2. LoukasPap commented on Apr 22, 2026

    @LoukasPap
    Contributor

    So, do we want to implement it as a GNU extension even if the POSIX flag is used? If so, the fix will probably be in the condition below to guide the execution correctly.

    sed/src/sed/compiler.rs

    Lines 1123 to 1127 in ebb321e

    if context.posix {
    compile_text_command_posix(lines, line, cmd, context)
    } else {
    compile_text_command_gnu(lines, line, cmd, context)
    }

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