pub fn resolve_binary<P: AsRef<Path>>(prog: P) -> Result<PathBuf, CommandError>
Resolves a path to a program to a path by searching for the program in
If the program could not be resolved, then an error is returned.
The purpose of doing this instead of passing the path to the program directly to Command::new is that Command::new will hand relative paths to CreateProcess on Windows, which will implicitly search the current working directory for the executable. This could be undesirable for security reasons. e.g., running ripgrep with the -z/–search-zip flag on an untrusted directory tree could result in arbitrary programs executing on Windows.
Note that this could still return a relative path if PATH contains a relative path. We permit this since it is assumed that the user has set this explicitly, and thus, desires this behavior.
On non-Windows, this is a no-op.