This pull request adds a new method resolve() to the lang.CommandLine class which finds executables in the system path. This method supersedes lang.Process::resolve() which is therefore deprecated.
# Windows
$ xp -w '[...lang\CommandLine::forName(PHP_OS)->resolve("curl")]'
["C:\Tools\Cygwin\bin\curl.exe", "C:\Windows\System32\curl.exe"]
# Un*x
$ xp -w '[...lang\CommandLine::forName(PHP_OS)->resolve("which")]'
["/usr/bin/which", "/bin/which"]
Windows
If the given name does not contain a ".", try [name].exe and [name].com for both of the following
If the given argument contains a "\" or "/", check whether a file by the given name exists
Otherwise, iterate over paths in %PATH% and check for qualified file names
Note: If you want to execute .bat files, you need to use cmd /c [file].bat in order for this to work!
Un*x
If the name contains the directory separato char (typically "/"), check whether a file by the given name exists and has executable bit set
Otherwise, iterate over paths in $PATH and check for qualified file names
Note: The executable bit must be set effectively for the current user for a file to be regarded executable
This pull request adds a new method
resolve()
to thelang.CommandLine
class which finds executables in the system path. This method supersedeslang.Process::resolve()
which is therefore deprecated.Windows
[name].exe
and[name].com
for both of the followingNote: If you want to execute .bat files, you need to use
cmd /c [file].bat
in order for this to work!Un*x
Note: The executable bit must be set effectively for the current user for a file to be regarded executable