Browse Source

* rename System::type to System::which

migration/unlabaled-1.29.2
Stig Bakken 23 years ago
parent
commit
846ad56a13
  1. 8
      pear/System.php
  2. 10
      pear/tests/pear_system.phpt

8
pear/System.php

@ -411,17 +411,17 @@ class System
}
/**
* The "type" command (show the full path of a command)
* The "which" command (show the full path of a command)
*
* @param string $program The command to search for
* @return mixed A string with the full path or false if not found
* @author Stig Bakken <ssb@fast.no>
*/
function type($program)
function which($program, $fallback = false)
{
// full path given
if (basename($program) != $program) {
return (@is_executable($program)) ? $program : false;
return (@is_executable($program)) ? $program : $fallback;
}
// XXX FIXME honor safe mode
$path_delim = OS_WINDOWS ? ';' : ':';
@ -433,7 +433,7 @@ class System
return $file;
}
}
return false;
return $fallback;
}
}
?>

10
pear/tests/pear_system.phpt

@ -72,15 +72,15 @@ if (!@System::rm("-r $del")) {
}
/*******************
type
which
********************/
if (OS_UNIX) {
if (System::type('ls') != '/bin/ls') {
print "System::type('ls') failed\n";
if (System::which('ls') != '/bin/ls') {
print "System::which('ls') failed\n";
}
if (System::type('i_am_not_a_command')) {
print "System::type('i_am_not_a_command') did not failed\n";
if (System::which('i_am_not_a_command')) {
print "System::which('i_am_not_a_command') did not failed\n";
}
} // XXX Windows test

Loading…
Cancel
Save