Skip to content

s&a&b& fails with "unterminated substitute replacement" #697

Open

Description

@kevinburkesegment

When & is the delimiter of an s command, the replacement never ends:

$ echo a | sed 's&a&b&'
sed: <script argument 1>:1:7: error: unterminated substitute replacement

This should replace 'a' with 'b' and then output 'b'. Other delimiters work, but this one doesn't.

This is because the parser treats '&' as the matched text before it performs the delimiter check. In practice I hit this trying to install a Python version from Pyenv, autoconf's config.status uses '&' as a delimiter for sed, and it was failing. I have a patch ready.

Activity

  1. added 2 commits that reference this issue on Nov 17, 2026
    46d6871
    36b42ce
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