pathchk: reject an empty file name in portability modes to match GNU - #14069
Open
AlejandroCoronadoN wants to merge 1 commit into
Open
pathchk: reject an empty file name in portability modes to match GNU#14069AlejandroCoronadoN wants to merge 1 commit into
AlejandroCoronadoN wants to merge 1 commit into
Conversation
|
GNU testsuite comparison: |
cakebaker
reviewed
Aug 22, 2026
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; | ||
| } |
Contributor
There was a problem hiding this comment.
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.
cakebaker
reviewed
Aug 22, 2026
Comment on lines
173
to
174
| // fail on empty path | ||
| new_ucmd!().args(&["-p", "-P", ""]).fails().no_stdout(); |
Contributor
There was a problem hiding this comment.
You can remove this test as it tests the same as your test, though your test is better.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
pathchk's portability modes (-p,-P,--portability), an empty file name diverges from GNU:-Pprintspathchk: '': No such file or directory(it runs the filesystem check first and never reaches the empty-name check).-pand--portabilityprintempty file namewithout thepathchk:prefix.GNU rejects an empty file name in any portability mode before touching the filesystem, always as
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.