Skip to content

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

Open
AlejandroCoronadoN wants to merge 1 commit 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 1 commit 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

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/misc/tty-eof (fails in this run but passes in the 'main' branch)

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.

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.

2 participants