Skip to content

-e "i\\6IlzWb" is failing when accepted by GNU #86

Closed

Description

@sylvestre

with our impl:

echo "qqGG3" |cargo run sed -e "i\\6IlzWb"
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/sedapp sed -e 'i\6IlzWb'`
sed: i\6IlzWb:1:2: error: extra characters after \ at the end of `i' command

With GNU:

echo "qqGG3" |sed -e "i\\6IlzWb"
6IlzWb
qqGG3

Activity

  1. dspinellis commented on Jul 26, 2025

    @dspinellis
    Collaborator

    Further GNU sed examples:

    # Backslash is optional
    $ echo hi | sed 'athere'
    hi
    there
    $
    
    # Spaces preceding the text are ignored
    $ echo hi | sed 'a there'
    hi
    there
    $
    
    # EOF after EOL
    $ echo hi | sed $'a\n'
    hi
    
    $
    
    # EOF after \
    $ echo hi | sed $'a\\\n'
    hi
    
    $
    
    # First \ doesn't result in escaped characters
    $ echo hi | sed 'a\tom'
    hi
    tom
    $
    
    # Text can follow the initial \
    # Character escapes are supported
    # Invalid escapes result in the character
    $ echo mankind | sed $'i\\>\\h\\elll\bo\\nto\\\nall\\a'
    >hello
    to
    all
    mankind
  2. dspinellis commented on Jul 27, 2025

    @dspinellis
    Collaborator

    @sylvestre I fixed it:

    $ echo "qqGG3" | target/debug/sedapp sed -e 'i\6IlzWb'
    6IlzWb
    qqGG3
    
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