add fallback for when binary is not in path

This commit is contained in:
Robin Appelman 2022-05-25 16:53:26 +02:00
commit f8cbc6081b

View file

@ -62,7 +62,14 @@ class System implements ISystem {
$result = null; $result = null;
$output = []; $output = [];
exec("which $binary 2>&1", $output, $result); exec("which $binary 2>&1", $output, $result);
$this->paths[$binary] = $result === 0 && isset($output[0]) ? (string)$output[0] : null;
if ($result === 0 && isset($output[0])) {
$this->paths[$binary] = (string)$output[0];
} else if (is_executable("/usr/bin/$binary")) {
$this->paths[$binary] = "/usr/bin/$binary";
} else {
$this->paths[$binary] = null;
}
} }
return $this->paths[$binary]; return $this->paths[$binary];
} }