fitzgen / is_executable

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

Check for extensions defined in PATHEXT on Windows #5

Closed martonlanga closed 3 years ago

martonlanga commented 3 years ago

Currently on Windows executables with extensions defined in PATHEXT are ignored.

Is this something you would support in your library?

Existing implementation examples

alpha-tango-kilo commented 3 years ago

I could probably write a PR for this, given the example code seems pretty clear.

@martonlanga what's the use case for this though over what the library already provides? Are there some cases where PATHEXT will determine a file executable where this crate wouldn't, or is this just an alternative implementation?

martonlanga commented 3 years ago

@alpha-tango-kilo I've replaced is_executable in my project with nushell's sample because the current version of this crate doesn't recognize certain executables as such.

Usually it's an external command that gets ignored (eg.: yarn.cmd).

alpha-tango-kilo commented 3 years ago

Okay, so does that make it a complete replacement for the current implementation or should it complement it?

I would imagine a file with its extension removed would be classified as runnable by this crate but not when tested using PATHEXT, are you able to confirm this?

martonlanga commented 3 years ago

I'm fine with a complete replacement, but you should ask @fitzgen about this.

Not entirely sure what you mean by this. Currently this crate only checks whether the provided path is executable or not. On Windows, I would expect this library to also check against the path joined with all the extensions defined in PATHEXT.

So if PATH_TO_YARN\yarn is not a valid path, it should check whether PATH_TO_YARN\yarn.exe, PATH_TO_YARN\yarn.cmd, ... is a valid path.