Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pathchk: check empty path by default #5423

Merged
merged 3 commits into from
Oct 19, 2023

Conversation

Luv-Ray
Copy link
Contributor

@Luv-Ray Luv-Ray commented Oct 18, 2023

fix #5314
comment in GNU pathchk:

Check whether a file name component is in a directory that is not searchable, or has some other serious problem. POSIX does not allow "" as a file name, but some non-POSIX hosts do (as an alias for "."), so allow "" if lstat does.

I use std::fs::symlink_metadata, which currently corresponds to the lstat function on Unix and the GetFileInformationByHandle function on Windows instead.

It looks good in my local, but I don't have a non-POSIX environment, so it may need some more tests.
In my local:

$ ./target/debug/pathchk ""         
pathchk: '': No such file or directory
$ ./target/debug/pathchk "" ""      
pathchk: '': No such file or directory
pathchk: '': No such file or directory

// accept empty path
new_ucmd!().args(&[""]).succeeds().no_stdout();
// fail on empty path
new_ucmd!().args(&[""]).fails().no_stdout();
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

please check the error message too :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have change no_stdout to stderr_only :)

@cakebaker cakebaker merged commit a3c6d6d into uutils:main Oct 19, 2023
44 of 45 checks passed
@cakebaker
Copy link
Contributor

Thanks :)

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.

pathchk "" shoud give an error
3 participants