Skip to content

Add support for address range commands (GNU extension) - #260

Merged
sylvestre merged 1 commit into
uutils:mainfrom
LoukasPap:main
Mar 19, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
LoukasPap:main

Conversation

@LoukasPap

@LoukasPap LoukasPap commented Jan 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes issue 234

  • Add GNU extension for 2 supported addresses for a, i and = commands
  • Make n_addr conditional based on POSIX flag

@github-actions

Copy link
Copy Markdown

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 8 / FAILED: 56 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 8 / FAILED: 56 / SKIPPED: 0

@codecov

codecov Bot commented Jan 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.16%. Comparing base (27da027) to head (73d8126).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/sed/compiler.rs 90.32% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #260      +/-   ##
==========================================
+ Coverage   82.14%   82.16%   +0.02%     
==========================================
  Files          13       13              
  Lines        5437     5444       +7     
  Branches      300      304       +4     
==========================================
+ Hits         4466     4473       +7     
  Misses        969      969              
  Partials        2        2              
Flag Coverage Δ
macos_latest 82.61% <90.32%> (+0.02%) ⬆️
ubuntu_latest 82.72% <90.32%> (+0.02%) ⬆️
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 Sentry.
📢 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.

@github-actions

Copy link
Copy Markdown

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 8 / FAILED: 56 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 8 / FAILED: 56 / SKIPPED: 0

@dspinellis

Copy link
Copy Markdown
Collaborator

Thank you! This is a GNU extension, so the feature should not be available under --posix. Please also squash all commits into one.

@LoukasPap

Copy link
Copy Markdown
Contributor Author

Got it! I'll fix these and push again.

@LoukasPap

LoukasPap commented Jan 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Found out that the problem happens with the l (list) command too (we allow address range with --posix enabled but it should not be allowed). Should I fix it here or open a different issue for this?

@dspinellis

Copy link
Copy Markdown
Collaborator

I'd suggest one commit for all commands. Try to unify the check for POSIX.

@github-actions

Copy link
Copy Markdown

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0

2 similar comments
@github-actions

Copy link
Copy Markdown

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0

@github-actions

Copy link
Copy Markdown

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0

@LoukasPap
LoukasPap force-pushed the main branch 2 times, most recently from 81e0901 to 698f2b7 Compare January 21, 2026 17:07
@LoukasPap

LoukasPap commented Jan 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Squashed all my commits having removed the merge commit which was not mine.

The POSIX check now happens in one place. I will update the README.md too.

Comment thread src/sed/compiler.rs Resolved
@github-actions

Copy link
Copy Markdown

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0

@github-actions

Copy link
Copy Markdown

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0

@dspinellis

Copy link
Copy Markdown
Collaborator

I see you're progressing! Try running the various CI tasks locally to avoid CI failures. Please also close the PRs that you've folded into this one.

@codspeed

codspeed Bot commented Jan 22, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 2.27%

⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 8 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ access_log_translit 784.5 ms 757.5 ms +3.56%
❌ no_op_short 955.6 ms 977.8 ms -2.27%
⚡ number_fix 519.8 ms 506.1 ms +2.7%

Comparing LoukasPap:main (73d8126) with main (16f1145)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (27da027) during the generation of this report, so 16f1145 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@LoukasPap

Copy link
Copy Markdown
Contributor Author

These two tests are failing because the supported addresses are now 2 and not 1 (like the tests assert):

  1. test_lookup_text_command

    sed/src/sed/compiler.rs

    Lines 1309 to 1314 in 398ee76

    #[test]
    fn test_lookup_text_command() {
    let (lines, line) = make_providers("123abc");
    let cmd = get_cmd_spec(&lines, &line, 'a').unwrap();
    assert_eq!(cmd.n_addr, 1);
    }
  2. test_valid_command_spec

    sed/src/sed/compiler.rs

    Lines 1416 to 1425 in 398ee76

    #[test]
    fn test_valid_command_spec() {
    let lines = ScriptLineProvider::with_active_state("input.sed", 4);
    let line = char_provider_from("a"); // valid command
    let result = get_verified_cmd_spec(&lines, &line, 1);
    assert!(result.is_ok());
    let spec = result.unwrap();
    assert_eq!(spec.n_addr, 1);
    }

Would it be "correct" to change the tests to check for 2 addresses; What I mean is, do these tests represent the standard sed behavior (1 address) and not the 'GNU-extended' behavior (with 2 addresses) and thus changing them would be wrong?

I hope I am clear :)

Comment thread src/sed/command.rs Resolved
@dspinellis

Copy link
Copy Markdown
Collaborator

I would expect that rather than storing / returning a number you would store

These two tests are failing because the supported addresses are now 2 and not 1 (like the tests assert):

1. `test_lookup_text_command`
   https://github.com/uutils/sed/blob/398ee76b79ba52768c1df214d516b2ad5c173882/src/sed/compiler.rs#L1309-L1314

2. `test_valid_command_spec`
   https://github.com/uutils/sed/blob/398ee76b79ba52768c1df214d516b2ad5c173882/src/sed/compiler.rs#L1416-L1425

Would it be "correct" to change the tests to check for 2 addresses; What I mean is, do these tests represent the standard sed behavior (1 address) and not the 'GNU-extended' behavior (with 2 addresses) and thus changing them would be wrong?

I hope I am clear :)

I suggest that you also store and process n_addr_posix and add corresponding tests.

@dspinellis dspinellis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please consider the initial comments I made on the code and fix the CI errors. Will then follow-up with a more complete review.

Comment thread src/sed/compiler.rs Resolved
@LoukasPap LoukasPap changed the title Fix address range difference for line number command Add support for address range (GNU extension) Jan 24, 2026
@LoukasPap LoukasPap changed the title Add support for address range (GNU extension) Add support for address range commands (GNU extension) Jan 24, 2026
@LoukasPap

LoukasPap commented Jan 24, 2026 •

Copy link
Copy Markdown
Contributor Author

I see you're progressing! Try running the various CI tasks locally to avoid CI failures. Please also close the PRs that you've folded into this one.

Thank you for helping me out! Indeed, I recently noticed I could run the CI tasks locally. It will be much faster than pushing and then checking for errors.

Please consider the initial comments I made on the code and fix the CI errors. Will then follow-up with a more complete review.

Yes, I will finish this issue before moving to another. For a reason, I hadn't noticed your new comments and I was searching for another issue while I was waiting.

@github-actions

Copy link
Copy Markdown

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0

@github-actions

Copy link
Copy Markdown

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0

@github-actions

Copy link
Copy Markdown

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0
  Reference: TOTAL: 64 / PASSED: 15 / FAILED: 49 / SKIPPED: 0

@LoukasPap
LoukasPap marked this pull request as draft March 14, 2026 15:55
@LoukasPap
LoukasPap marked this pull request as ready for review March 14, 2026 16:00
@LoukasPap

Copy link
Copy Markdown
Contributor Author

Returning to that issue, are there any other changes to be made? Or, is the approach to the problem "correct"? Maybe simpler/cleaner solutions exist.

Comment thread src/sed/compiler.rs Resolved
Comment thread README.md Resolved
Comment thread src/sed/compiler.rs Resolved
Comment thread src/sed/compiler.rs Resolved
Comment thread src/sed/compiler.rs Resolved
Comment thread src/sed/compiler.rs Resolved
@dspinellis

Copy link
Copy Markdown
Collaborator

@sylvestre I think we were reviewing concurrently. Would the proposed scheme for a single field address your concerns? What's your opinion regarding it?

@sylvestre

Copy link
Copy Markdown
Contributor

sure, sounds good :)

…based on POSIX flag

- Update `get_cmd_spec()` and `get_verified_cmd_spec()` to accept a boolean POSIX param
- Add unit and high level tests
- Update README.md
@sylvestre

Copy link
Copy Markdown
Contributor

@dspinellis ok with you ? :)

@dspinellis

Copy link
Copy Markdown
Collaborator

@dspinellis ok with you ? :)

LGTM

@sylvestre
sylvestre merged commit 5e9b821 into uutils:main Mar 19, 2026
25 of 27 checks passed
@LoukasPap
LoukasPap deleted the main branch August 31, 2026 13:18
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.

Address range validation difference for line number command

3 participants