Skip to content

sed: accept blanks and a missing number after + in addr1,+N - #662

Merged
sylvestre merged 1 commit into
uutils:mainfrom
sarankumar1325:fix/relative-range-blank-number
Nov 9, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
sarankumar1325:fix/relative-range-blank-number

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

Fixes #651

GNU sed skips blanks between the + of an addr1,+N range and its number, and reads a missing number as 0. uutils sed failed both with number expected:

$ seq 4 | sed '2,+ 1d'   # GNU: 1 4
$ seq 4 | sed '2,+d'     # GNU: 1 3 4

compile_address now skips blanks after + and parses the number as optional, defaulting to 0. 2,+1d is unchanged.

It uses the existing eat_spaces, like the rest of the address parser, so it follows whatever #654 decides about which blanks count.

Tests:

  • integration test_relative_range_blank_or_missing_number (space, tab, missing number, plain +1; fails on main)
  • unit test_compile_addr_relative_line_blank_and_missing_number in compiler.rs
  • cargo test, cargo fmt --check and cargo clippy --all-targets -- -D warnings pass locally

I used an AI assistant (Grok Bot) to help write this change. I reviewed the diff, compared the behaviour with GNU sed 4.9 on my machine and ran the tests above.

GNU sed skips blanks between the + of an addr1,+N range and its number,
and reads a missing number as 0. Do the same instead of failing with
"number expected".

Fixes uutils#651
Copilot AI balanced review requested due to automatic review settings November 9, 2026 16:16

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.25%. Comparing base (5e2821e) to head (d74ba6e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #662   +/-   ##
=======================================
  Coverage   95.24%   95.25%           
=======================================
  Files          14       14           
  Lines        7490     7500   +10     
  Branches      442      442           
=======================================
+ Hits         7134     7144   +10     
  Misses        355      355           
  Partials        1        1           
Flag Coverage Δ
macos_latest 96.74% <100.00%> (+<0.01%) ⬆️
ubuntu_latest 96.68% <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.

@sylvestre
sylvestre merged commit 6ae5577 into uutils:main Nov 9, 2026
30 of 31 checks passed
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.

sed - addr1,+N rejects a blank after + or a missing N

3 participants