OpamSystem.t_resolve_command: use ocaml code for looking up commands in PATH #4072
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
...instead of calling the shell (on linux).
The motivation is performance. It turns out that the speedup of #4064 is due not only to less time being spent launching processes, but also less time being spent calling to the shell in order to resolve the command. Doing the resolution (using PATH) directly in ocaml should be faster.
Note that command resolution was already done in ocaml on Windows, so this PR mostly merges the (previously) windows-specific code with the linux code.
The PR also attempts to streamline a bit the handling of
Not_found
vsDenied
. The behavior is mostly unchanged when looking up a fully specified path (I added aNot_found
case for increased precision; previously, a non-existing binary would be reported as "denied").When a command is looked up in
PATH
, I follow the shell behavior a bit more consistently (as specified here "Other environment variables) and skip binaries that do not have the right permissions.If no suitable binary is found, then
Not_found
is returned (the previous code was inconsistent: it would've returnedDenied
under windows, butNot_found
under linux).