Skip to content

sed: report repeated substitute flags with GNU's messages - #611

Open
sylvestre wants to merge 2 commits into
uutils:mainfrom
sylvestre:sed-subst-flag-messages
Open

sylvestre wants to merge 2 commits into
uutils:mainfrom
sylvestre:sed-subst-flag-messages

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

Depends on #610: this branch contains its commit. Review only the last commit.

Splits "multiple 'g' or numeric flags in substitute command" into GNU's "multiple g' options to s' command" and "multiple number options to s' command". The latter is raised at the second number, so the caret for s/a/b/2g3sits under the3(char 9, like GNU) instead of theg`.

`s/x/y/2g` (replace the 2nd match and every later one) and `s/x/y/g2`
are valid in GNU sed, but were rejected with "multiple 'g' or numeric
flags". Track `g` separately from the occurrence number so the two can
be combined; repeating either one is still an error.
Split "multiple 'g' or numeric flags in substitute command" into
GNU's "multiple `g' options to `s' command" and "multiple number
options to `s' command". The latter is raised at the second number, so
the caret for `s/a/b/2g3` sits under the `3`, at char 9 like GNU.
@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.85%. Comparing base (b1ea0dc) to head (d800bd1).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #611   +/-   ##
=======================================
  Coverage   94.85%   94.85%           
=======================================
  Files          14       14           
  Lines        7230     7235    +5     
  Branches      432      432           
=======================================
+ Hits         6858     6863    +5     
  Misses        371      371           
  Partials        1        1           
Flag Coverage Δ
macos_latest 96.39% <100.00%> (+<0.01%) ⬆️
ubuntu_latest 96.33% <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

The final commit’s diagnostic changes and regression assertions are consistent, with no blocking issues identified.

No open issues 🎉

What changed in this PR

The final commit aligns repeated substitute-flag diagnostics with GNU sed, building on the combined numeric/g support from #610.

Changes:

  • Distinguishes repeated g flags from repeated numeric flags.
  • Adds regression assertions for error wording and the second number’s diagnostic position.
File Description
tests/​by-util/​test_sed.rs Adds a regression test for the diagnostic underline.
src/​sed/​processor.rs Contains prerequisite #610 substitution behavior; outside this review’s scope.
src/​sed/​compiler.rs Updates diagnostic messages and unit assertions.
src/​sed/​command.rs Contains prerequisite #610 global-flag state; outside this review’s scope.

Review effort: Balanced

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.

2 participants