22use Wikimedia\AtEase\AtEase;
39 return array_unique( array_merge(
40 [
'/usr/bin',
'/bin',
'/usr/local/bin',
'/opt/csw/bin',
41 '/usr/gnu/bin',
'/usr/sfw/bin',
'/sw/bin',
'/opt/local/bin' ],
42 explode( PATH_SEPARATOR, getenv(
'PATH' ) )
64 $command =
$path . DIRECTORY_SEPARATOR . $name;
66 AtEase::suppressWarnings();
67 $file_exists = is_executable( $command );
68 AtEase::restoreWarnings();
71 if ( !$versionInfo ) {
75 $output = Shell::command( $command, $versionInfo[0] )
76 ->includeStderr()->execute()->getStdout();
77 if ( str_contains( $output, $versionInfo[1] ) ) {
98 if ( Shell::isDisabled() ) {
103 $paths = self::getPossibleBinPaths();
104 foreach ( (array)$names as $name ) {
105 foreach ( $paths as
$path ) {
106 $exe = self::findExecutable(
$path, $name, $versionInfo );
107 if ( $exe !==
false ) {
Utility class to find executables in likely places.
static getPossibleBinPaths()
Get an array of likely places we can find executables.
static findExecutable( $path, $name, $versionInfo=false)
Search a path for any of the given executable names.
static findInDefaultPaths( $names, $versionInfo=false)
Same as locateExecutable(), but checks in getPossibleBinPaths() by default.