Repository navigation
sed: end an s replacement at an & delimiter - #698
kevinburkesegment wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 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]>
46d6871 to
36b42ce
Compare
There was a problem hiding this comment.
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
| "-e", | ||
| ":t", | ||
| "-e", | ||
| r"s&@srcdir@&.&;t t", |
There was a problem hiding this comment.
could be simpler, no? a plain s&a&b& on "a" shows the bug, the :t loop isn't needed
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