cvs: php-src /pear/scripts pearcmd.php
| From: | Greg Beaver | Date: | Sun, 06 Jun 2004 15:04:16 +0000 |
| Subject: | cvs: php-src /pear/scripts pearcmd.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-369@lists.php.net to get a copy of this message | ||
cellog Sun Jun 6 11:04:16 2004 EDT
Modified files:
/php-src/pear/scripts pearcmd.php
Log:
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.
http://cvs.php.net/diff.php/php-src/pear/scripts/pearcmd.php?r1=1.10&r2=1.11&ty=u
Index: php-src/pear/scripts/pearcmd.php
diff -u php-src/pear/scripts/pearcmd.php:1.10 php-src/pear/scripts/pearcmd.php:1.11
--- php-src/pear/scripts/pearcmd.php:1.10 Sat Mar 13 12:37:23 2004
+++ php-src/pear/scripts/pearcmd.php Sun Jun 6 11:04:16 2004
@@ -18,7 +18,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: pearcmd.php,v 1.10 2004/03/13 17:37:23 cellog Exp $
+// $Id: pearcmd.php,v 1.11 2004/06/06 15:04:16 cellog Exp $
ob_end_clean();
/**
@@ -50,8 +50,12 @@
$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 @@
$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;