Skip to content

sed: copy R text and e command output unchanged, as GNU sed does - #590

Closed
DePasqualeOrg wants to merge 1 commit into
uutils:mainfrom
DePasqualeOrg:fix-raw-r-and-e-output
Closed

DePasqualeOrg wants to merge 1 commit into
uutils:mainfrom
DePasqualeOrg:fix-raw-r-and-e-output

Conversation

@DePasqualeOrg

@DePasqualeOrg DePasqualeOrg commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Please ignore this PR until it is marked as ready for review


GNU sed copies the line that R reads, and the output of the e command form, to the output exactly as they are. uutils sed treats them as lines and adds a newline when they lack one. With a file f that contains x and no newline, printf 'a\nb\n' | sed 'R f' prints x and b on separate lines, while GNU sed prints xb. Likewise, printf 'a\n' | sed '1e printf hi' prints hi on a line of its own, while GNU sed prints hia.

This PR adds OutputBuffer::write_raw, which writes a newline that the previous output line lacks and then the bytes unchanged, and uses it for appended text and e output. It also makes l print $ for an empty pattern space whose line lacked a newline, as GNU sed does.

codecov/patch fails only because CI does not count the coverage of tests that run the sed binary; it should pass after #591 is merged.

@codspeed

codspeed Bot commented Oct 2, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 35.38%

⚠️ 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
⚡ access_log_append 1.5 s 1.1 s +35.38%

Tip

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


Comparing DePasqualeOrg:fix-raw-r-and-e-output (35f178a) with main (1113479)

Open in CodSpeed

@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.91%. Comparing base (1113479) to head (35f178a).

Files with missing lines Patch % Lines
src/sed/processor.rs 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #590      +/-   ##
==========================================
+ Coverage   83.86%   83.91%   +0.04%     
==========================================
  Files          14       14              
  Lines        7203     7206       +3     
  Branches      424      423       -1     
==========================================
+ Hits         6041     6047       +6     
+ Misses       1157     1154       -3     
  Partials        5        5              
Flag Coverage Δ
macos_latest 85.03% <75.00%> (+0.04%) ⬆️
ubuntu_latest 85.22% <75.00%> (+0.04%) ⬆️
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.

@DePasqualeOrg

Copy link
Copy Markdown
Contributor Author

Closing: this change is now part of #589, because each needed the other.

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