Skip to content

Support F (output filename) command - #528

Merged
sylvestre merged 1 commit into
uutils:mainfrom
dspinellis:F-command
Aug 19, 2026
Merged

Support F (output filename) command#528
sylvestre merged 1 commit into
uutils:mainfrom
dspinellis:F-command

Conversation

@dspinellis

Copy link
Copy Markdown
Collaborator

This also requires storing input_name as PathBuf to avoid lossy conversions when outputting an OS-specific byte sequence representing the file name.

Copilot AI lite review requested due to automatic review settings August 19, 2026 08:24
This also requires storing input_name as PathBuf to avoid lossy
conversions when outputting an OS-specific byte sequence representing
the file name.

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.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds support for sed’s non-POSIX F command (print current input filename), including switching runtime tracking of the current input name to PathBuf to avoid lossy string conversions.

Changes:

  • Implement F command execution in the sed processor by writing the current input filename bytes + newline.
  • Change ProcessingContext.input_name from a quoted String to a PathBuf, and update error formatting accordingly.
  • Add/extend tests and fixtures to cover filename output for files, stdin (-), non-ASCII filenames, and --posix rejection.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/fixtures/sed/output/filename_file Adds expected output fixture for running F over input/lines1.
tests/by-util/test_sed.rs Adds test cases for F (file, non-ASCII filename, stdin, and --posix).
src/sed/processor.rs Implements F command behavior; updates file iteration so PathBuf can be moved into context.
src/sed/mod.rs Initializes input_name as PathBuf (- for stdin).
src/sed/error_handling.rs Updates runtime error formatting to quote PathBuf input names.
src/sed/compiler.rs Allows F only in non-POSIX mode.
src/sed/command.rs Changes ProcessingContext.input_name type to PathBuf.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/by-util/test_sed.rs
Comment thread src/sed/processor.rs
Comment thread src/sed/processor.rs
Copilot AI review requested due to automatic review settings August 19, 2026 08:41

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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/sed/processor.rs:744

  • This allocates a new Vec<u8> for every F execution (per input line), which can be expensive on large inputs. Consider avoiding allocation by writing the filename bytes and the trailing newline as separate writes (or via an API that appends a newline without cloning), while keeping the non-lossy as_encoded_bytes() behavior.
                'F' => {
                    // Output current input file name.
                    let mut bytes = context.input_name.as_os_str().as_encoded_bytes().to_vec();
                    bytes.push(b'\n');
                    output.write_bytes(&bytes)?;
                }

src/sed/mod.rs:251

  • Switching the default stdin name from \"<stdin>\" to \"-\" is a visible behavior change beyond the new F command. Since context.input_name is also used in runtime error messages (now via .quote()), diagnostics for stdin will change accordingly. If only F should emit - while diagnostics should remain \"<stdin>\", consider keeping a separate display string for errors vs. the raw PathBuf used for F output.
        input_name: PathBuf::from("-"),

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 7.69231% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.18%. Comparing base (d837ddf) to head (8b4ed6d).

Files with missing lines Patch % Lines
src/sed/processor.rs 0.00% 7 Missing ⚠️
src/sed/compiler.rs 0.00% 4 Missing ⚠️
src/sed/error_handling.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #528      +/-   ##
==========================================
- Coverage   83.27%   83.18%   -0.09%     
==========================================
  Files          13       13              
  Lines        6994     7001       +7     
  Branches      397      398       +1     
==========================================
  Hits         5824     5824              
- Misses       1167     1174       +7     
  Partials        3        3              
Flag Coverage Δ
macos_latest 83.83% <7.69%> (-0.09%) ⬇️
ubuntu_latest 84.03% <7.69%> (-0.09%) ⬇️
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.

@codspeed-hq

codspeed-hq Bot commented Aug 19, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 6.17%

⚠️ 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 regressed benchmark
✅ 10 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
number_fix 1.4 s 1.5 s -6.17%

Tip

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


Comparing dspinellis:F-command (8b4ed6d) with main (d837ddf)

Open in CodSpeed

@sylvestre sylvestre left a comment

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.

LGTM, thanks!

@sylvestre
sylvestre merged commit 3f72f93 into uutils:main Aug 19, 2026
27 of 30 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.

3 participants