fitzgen / is_executable

Is there an executable file at the given path?
Apache License 2.0
17 stars 8 forks source link

Missing `is_symlink` check? #9

Open wooster0 opened 3 years ago

wooster0 commented 3 years ago

This is is_executable of is_executable: https://github.com/fitzgen/is_executable/blob/master/src/lib.rs#L90-L97 This is is_executable of nushell: https://github.com/nushell/nushell/blob/b39dda05500d92b627685b8251bfe416dc621c08/crates/nu-completion/src/command.rs#L73-L86 If you compare them you will notice that nushell has an additional is_symlink() check but is_executable's is_executable does not. Is this intentional or is there potentially an unintended omission?

waywardmonkeys commented 3 years ago

@fitzgen I'd be happy to submit a PR for this if you agree that it should check for being a symlink. But perhaps it should check to see if the symlink target exists and is a file?

waywardmonkeys commented 3 years ago

Looking further, the std::fs::metadata already should be peeking at the target file, not the actual symlink itself.

waywardmonkeys commented 3 years ago

Docs: https://doc.rust-lang.org/std/fs/fn.metadata.html

fitzgen commented 3 years ago

For my usecase when I wrote this crate, I would have been fine with following symlinks and essentially answering whether the thing that the symlink points to was executable or not. I realize that may or may not be what other users want. Maybe makes sense to have it configurable.