diff options
author | Greg Beaver <cellog@php.net> | 2004-06-06 15:04:16 +0000 |
---|---|---|
committer | Greg Beaver <cellog@php.net> | 2004-06-06 15:04:16 +0000 |
commit | 84d9651b617903a229a1900498703dde2957d442 (patch) | |
tree | fc1fa187e15b4ef531e4c3337a289ac15e4bb8a8 /pear/scripts | |
parent | f0468116c0236f7b04e187596cb88246d2e9814f (diff) | |
download | php-git-84d9651b617903a229a1900498703dde2957d442.tar.gz |
eliminate the annoyance of upgrading from crapster versions of PEAR once and for all.
Now, if getopt2 exists, it is used, otherwise getopt is used.
Diffstat (limited to 'pear/scripts')
-rw-r--r-- | pear/scripts/pearcmd.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/pear/scripts/pearcmd.php b/pear/scripts/pearcmd.php index fcf6a6501b..c410c0a7f0 100644 --- a/pear/scripts/pearcmd.php +++ b/pear/scripts/pearcmd.php @@ -50,8 +50,12 @@ $all_commands = PEAR_Command::getCommands(); $argv = Console_Getopt::readPHPArgv(); /* $progname = basename($argv[0]); */ $progname = 'pear'; -array_shift($argv); -$options = Console_Getopt::getopt2($argv, "c:C:d:D:Gh?sSqu:vV"); +if (in_array('getopt2', get_class_methods('Console_Getopt'))) { + array_shift($argv); + $options = Console_Getopt::getopt2($argv, "c:C:d:D:Gh?sSqu:vV"); +} else { + $options = Console_Getopt::getopt($argv, "c:C:d:D:Gh?sSqu:vV"); +} if (PEAR::isError($options)) { usage($options); } @@ -158,8 +162,13 @@ if ($fetype == 'Gtk') { $short_args = $long_args = null; PEAR_Command::getGetoptArgs($command, $short_args, $long_args); - array_shift($options[1]); - if (PEAR::isError($tmp = Console_Getopt::getopt2($options[1], $short_args, $long_args))) { + if (in_array('getopt2', get_class_methods('Console_Getopt'))) { + array_shift($options[1]); + $tmp = Console_Getopt::getopt2($options[1], $short_args, $long_args); + } else { + $tmp = Console_Getopt::getopt($options[1], $short_args, $long_args); + } + if (PEAR::isError()) { break; } list($tmpopt, $params) = $tmp; |