Skip to content

pathchk: reject an empty file name in portability modes to match GNU - #14069

Open
AlejandroCoronadoN wants to merge 2 commits into
uutils:mainfrom
AlejandroCoronadoN:pathchk-empty-name-portability
Open

pathchk: reject an empty file name in portability modes to match GNU#14069
AlejandroCoronadoN wants to merge 2 commits into
uutils:mainfrom
AlejandroCoronadoN:pathchk-empty-name-portability

Conversation

@AlejandroCoronadoN

Copy link
Copy Markdown
Contributor

In pathchk's portability modes (-p, -P, --portability), an empty file name diverges from GNU:

  • -P prints pathchk: '': No such file or directory (it runs the filesystem check first and never reaches the empty-name check).
  • -p and --portability print empty file name without the pathchk: prefix.

GNU rejects an empty file name in any portability mode before touching the filesystem, always as pathchk: empty file name:

$ pathchk -P ''             # pathchk: '': No such file or directory   (GNU: pathchk: empty file name)
$ pathchk -p ''             # empty file name                          (GNU: pathchk: empty file name)
$ pathchk --portability ''  # empty file name                          (GNU: pathchk: empty file name)

This adds the early empty-name check (using the existing localized string) for all portability modes. Default mode (pathchk '') is unchanged.

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/dd/no-allocate is now passing!
Congrats! The gnu test tests/tail/tail-n0f is now passing!

Comment on lines +136 to +139
if !matches!(mode, Mode::Default) && path.join("/").is_empty() {
show_error!("{}", translate!("pathchk-error-empty-file-name"));
return false;
}

@cakebaker cakebaker Aug 22, 2026

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.

This change makes the "empty file name" checks in check_basic and check_extra unreachable if an empty file name is provided and so you can remove them.

Comment on lines 173 to 174
// fail on empty path
new_ucmd!().args(&["-p", "-P", ""]).fails().no_stdout();

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.

You can remove this test as it tests the same as your test, though your test is better.

@codspeed-hq

codspeed-hq Bot commented Aug 24, 2026

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

⚠️ 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
❌ 1 regressed benchmark
✅ 176 untouched benchmarks
⏩ 229 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation du_deep_tree[(100, 3)] 2.3 ms 2.3 ms -3.42%
Simulation du_wide_tree[(5000, 500)] 20.2 ms 19.5 ms +3.8%

Tip

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


Comparing AlejandroCoronadoN:pathchk-empty-name-portability (fa12706) with main (a9b64fc)2

Open in CodSpeed

Footnotes

  1. 229 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (71ebb92) during the generation of this report, so a9b64fc was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@codspeed-hq

codspeed-hq Bot commented Aug 24, 2026

Copy link
Copy Markdown

Unable to generate the performance report

There was an internal error while processing the run's data. We're working on fixing the issue. Feel free to contact us on Discord or at support@codspeed.io if the issue persists.

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