Skip to content

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
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
@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