Skip to content

sed: skip only spaces and tabs between script tokens - #665

Open
Himanshu-singh04 wants to merge 6 commits into
uutils:mainfrom
Himanshu-singh04:fix/654-script-blanks
Open

Himanshu-singh04 wants to merge 6 commits into
uutils:mainfrom
Himanshu-singh04:fix/654-script-blanks

Conversation

@Himanshu-singh04

Copy link
Copy Markdown
Contributor

Fixes #654.

Limit script blank skipping to space and tab. This prevents a trailing carriage return from being silently accepted after a command and preserves vertical tabs in one-line text.

Add unit coverage for other whitespace bytes and an integration regression for both behaviors.

Validation: cargo test --quiet; cargo fmt --check; cargo clippy --all-targets -- -D warnings; git diff --check.

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.43%. Comparing base (70960fc) to head (801afea).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #665   +/-   ##
=======================================
  Coverage   95.43%   95.43%           
=======================================
  Files          14       14           
  Lines        7730     7737    +7     
  Branches      460      461    +1     
=======================================
+ Hits         7377     7384    +7     
  Misses        352      352           
  Partials        1        1           
Flag Coverage Δ
macos_latest 96.89% <100.00%> (+<0.01%) ⬆️
ubuntu_latest 96.82% <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.

Comment thread tests/by-util/test_sed.rs Outdated

#[test]
fn test_script_parser_skips_only_space_and_tab() {
new_ucmd!().arg("p\r").fails().code_is(1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please also check the error message, not only the exit code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added an exact stderr assertion for the parser error in 66189c4, alongside the exit-code check. The integration tests pass locally.

Comment thread tests/by-util/test_sed.rs
.arg("1a\x0bfoo")
.pipe_in("a\n")
.succeeds()
.stdout_is("a\n\x0bfoo\n");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could you please add a case with a CRLF script read with -f? this is the one users will hit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a CRLF script-file case using -f in 1cb3c48. It now treats CRLF as a script-file line ending without treating carriage return as a general script blank. I also fixed substitution endings (} and #); subst-options passes against the GNU testsuite locally. The 367 integration tests and 408 unit tests pass.

@github-actions

Copy link
Copy Markdown

GNU sed testsuite comparison:

Test results comparison:
  Current:   TOTAL: 65 / PASSED: 21 / FAILED: 36 / SKIPPED: 8
  Reference: TOTAL: 65 / PASSED: 22 / FAILED: 35 / SKIPPED: 8

Changes from main branch:
  TOTAL: +0
  PASSED: -1
  FAILED: +1

New test failures (1):
  - subst-options

@codspeed

codspeed Bot commented Nov 15, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 3.86%

2 warnings

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 1 benchmark with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

❌ 1 regressed benchmark
✅ 10 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ access_log_translit 953.6 ms 991.9 ms -3.86%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Himanshu-singh04:fix/654-script-blanks (801afea) with main (70960fc)

Open in CodSpeed

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 - script parser skips CR, VT, FF (and 0x85, 0xA0) as blanks; GNU skips only space and tab

2 participants