Homec4science

Add Filesystem::resolveBinary to lookup full path to binary file in PATH

Authored by James Rhodes <jrhodes@redpointsoftware.com.au> on May 31 2013, 05:53.

Description

Add Filesystem::resolveBinary to lookup full path to binary file in PATH

Summary:
Arising out of an issue with D6070, I noticed that where on Windows actually returns all of the entries in PATH that match, rather than just the first. There's three places in the code that use where directly, one of which is in phutil for Filesystem::binaryExists (where the semantics don't affect it). The other two cases exist in Arcanist; the one introduced by D6070 and one in the JSHint linter.

This adds a Filesystem::resolveBinary method which is aware of the semantics of where on Windows and which on Linux. I'm recommending that code use this method to determine absolute paths to binaries in the PATH so that we don't encounter the same issue as occurred in D6070.

Test Plan:
Run the resolveBinary unit tests. The other unit tests for Filesystem are failing on my Windows box, presumably because they're trying to do UNIXy things.

The other thing you can do is replace the explicit usage of where with Filesystem::resolveBinary, like the place it's used in D6070 and confirm that it works as expected.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T3272

Differential Revision: https://secure.phabricator.com/D6077

Details

Committed
epriestley <git@epriestley.com>May 31 2013, 05:53
Pushed
aubortMar 17 2017, 12:03
Parents
rPHU1c637275046f: Fixing phutil_utf8_shorten().
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPHU378f7f23c84d: Add Filesystem::resolveBinary to lookup full path to binary file in PATH (authored by James Rhodes <jrhodes@redpointsoftware.com.au>).May 31 2013, 05:53