Skip to content

Implement zero-address r command to insert file before first line #426

Open
PranavRJoshi wants to merge 1 commit into
uutils:mainfrom
PranavRJoshi:feat/zero-address
Open

Implement zero-address r command to insert file before first line #426
PranavRJoshi wants to merge 1 commit into
uutils:mainfrom
PranavRJoshi:feat/zero-address

Conversation

@PranavRJoshi
Copy link
Copy Markdown

This PR introduces zero-address r command form as mentioned in #402.

What this does

Implements the r command for zero-address:

$ cat /tmp/r
X
Y

$ seq 5 | ./target/release/sed '0r/tmp/r'
X
Y
1
2
3
4
5

Changes

  • src/sed/compiler.rs: Checks for the r command and falls through if present. Three additional unit tests are introduced to handle: r command acceptance, zero-address only, and r command rejection.
  • src/sed/processor.rs: process_file pre-scans zero-address case before input line is read.
  • tests/by-util/test_sed.rs, tests/fixtures/sed/output/cmd_read_one_addr, and tests/fixtures/sed/output/cmd_read_zero_addr: Integration tests.

Note

  • GNU sed does not allow using R for zero-address:
$ seq 5 | ../gnu.sed/sed/sed '0R/tmp/r'
../gnu.sed/sed/sed: -e expression #1, char 2: invalid usage of line address 0

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 74.46809% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.15%. Comparing base (f083fa0) to head (499a268).

Files with missing lines Patch % Lines
src/sed/processor.rs 0.00% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #426      +/-   ##
==========================================
- Coverage   82.20%   82.15%   -0.06%     
==========================================
  Files          13       13              
  Lines        5542     5588      +46     
  Branches      310      314       +4     
==========================================
+ Hits         4556     4591      +35     
- Misses        983      994      +11     
  Partials        3        3              
Flag Coverage Δ
macos_latest 82.83% <74.46%> (-0.06%) ⬇️
ubuntu_latest 82.94% <74.46%> (-0.06%) ⬇️
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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 15, 2026

Merging this PR will improve performance by 2.63%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 10 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
genome_subst 215.5 ms 210 ms +2.63%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing PranavRJoshi:feat/zero-address (499a268) with main (f083fa0)

Open in CodSpeed

Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
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.

1 participant