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

help: mention that fd detects executables by file permissions #1106

Closed
matu3ba opened this issue Sep 7, 2022 · 7 comments · Fixed by #1169 or #1183
Closed

help: mention that fd detects executables by file permissions #1106

matu3ba opened this issue Sep 7, 2022 · 7 comments · Fixed by #1169 or #1183

Comments

@matu3ba
Copy link

matu3ba commented Sep 7, 2022

Detecting an executable efficiently is not simple: https://stackoverflow.com/questions/4458120/search-for-executable-files-using-find-command

fd uses the executable bit of the file permissions, which should be mentioned in the help page.

@sharkdp
Copy link
Owner

sharkdp commented Oct 31, 2022

I was not aware of this behavior. I think we should probably change the behavior of fd --type executable here to follow what find -executable does. What do others think?

@tavianator
Copy link
Collaborator

I'd be in favor of that. We can use the same library we do on Windows since #1061

@Ptipiak
Copy link
Contributor

Ptipiak commented Nov 11, 2022

As the last comment suggest I've made a pull request to use the faccess library,
I haven't find a way to implement the test for this behaviour, I'd like to know if it's relevant to do so ?

@tavianator
Copy link
Collaborator

The easiest test is something like touch file && chmod 005 file && fd --type executable file

@sharkdp
Copy link
Owner

sharkdp commented Nov 19, 2022

@Ptipiak Writing an integration test for this would be great.

@Ptipiak
Copy link
Contributor

Ptipiak commented Nov 22, 2022

Hi, I though about it right away, although I'm not sure how to create a file with a specific chmod in Rust, I might need to add a package

@tmccombs
Copy link
Collaborator

I think nix has chmod function, although you might need to enable an additional feature for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants