Skip to content

sed: end an s replacement at an & delimiter - #698

Open
kevinburkesegment wants to merge 1 commit into
uutils:mainfrom
kevinburkesegment:sed-ampersand-delimiter
Open

kevinburkesegment wants to merge 1 commit into
uutils:mainfrom
kevinburkesegment:sed-ampersand-delimiter

Conversation

@kevinburkesegment

Copy link
Copy Markdown
Contributor

compile_replacement matched an unescaped & as "the matched text" before checking for the delimiter, so with & as the delimiter the replacement never terminated: s&a&b& failed with "unterminated substitute replacement". Check the delimiter first. This is the form autoconf's config.status uses (s&@var@&value&), so it broke ./configure for CPython.

Fixes #697

Copilot AI balanced review requested due to automatic review settings November 17, 2026 19:09
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.44%. Comparing base (ce79163) to head (36b42ce).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #698   +/-   ##
=======================================
  Coverage   95.43%   95.44%           
=======================================
  Files          14       14           
  Lines        7740     7747    +7     
  Branches      467      468    +1     
=======================================
+ Hits         7387     7394    +7     
  Misses        352      352           
  Partials        1        1           
Flag Coverage Δ
macos_latest 96.89% <100.00%> (+<0.01%) ⬆️
ubuntu_latest 96.83% <100.00%> (+<0.01%) ⬆️
windows_latest 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the ampersand-delimited substitution fix.

No open issues 🎉

What changed in this PR

Fixes #697 by allowing & to terminate a substitution replacement when it is also the delimiter. This supports autoconf’s config.status substitution syntax, which previously failed during CPython configuration.

Changes:

  • Check for the closing delimiter before interpreting & as matched text.
  • Add regression tests covering escaped ampersands, trailing flags, and autoconf-style substitutions.
File Description
tests/​by-util/​test_sed.rs Adds an integration test for autoconf-style substitutions using & delimiters.
src/​sed/​compiler.rs Reorders replacement parsing and adds a focused unit test.

Review effort: Balanced

compile_replacement matched an unescaped & as "the matched text" before
checking for the delimiter, so with & as the delimiter the replacement
never terminated: `s&a&b&` failed with "unterminated substitute
replacement". Check the delimiter first. This is the form autoconf's
config.status uses (s&@var@&value&), so it broke ./configure for CPython.

Fixes uutils#697

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 17, 2026 21:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

No open issues 🎉

Review effort: Lite

Comment thread tests/by-util/test_sed.rs
"-e",
":t",
"-e",
r"s&@srcdir@&.&;t t",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be simpler, no? a plain s&a&b& on "a" shows the bug, the :t loop isn't needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants