Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.3

Bug #14684 console_getopt provides different results depending on platform used.
Submitted: 2008-09-22 00:13 UTC
From: kguest Assigned: cweiske
Status: Bogus Package: Console_Getopt (version 1.2.3)
PHP Version: 5.2.4 OS: Windows/Linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 26 + 18 = ?

 
 [2008-09-22 00:13 UTC] kguest (Ken Guest)
Description: ------------ with the command $ pear size -t doc,php -v pear_size on linux, the options and params variables passed to the doSize function, the $options and $params parameters passed ultimately from Console_Getopt to doSize are populated thus: Array ( [type] => doc,php [verbose] => 1 ) Array ( [0] => pear_size ) On Windows, with the same command, the arrays are populated by console_getopt as: Array ( [type] => doc ) Array ( [0] => php [1] => -v [2] => pear_size ) This discrepancy manifests itself as the bug that Laurent reported. The pearsize script does not have these problems as it utilizes Console_GetArgs rather than the console_getopt component. Actual result: -------------- would expect the options and params arrays to be filled identically irregardless of which platform is used.

Comments

 [2015-02-22 19:27 UTC] cweiske (Christian Weiske)
-Status: Open +Status: Bogus -Assigned To: +Assigned To: cweiske
This is not a bug in Console_Getopt. I get the same output on Windows and Linux for a sample script. Note that Console_Getopt does not merge short and long options into the same array; this is probably done by PEAR in your case. <?php // $ php console-getopt-14684.php -t doc,php -v pear_size require_once 'Console/Getopt.php'; $cg = new Console_Getopt(); $args = $cg->readPHPArgv(); array_shift($args); $shortOpts = 't:v'; $longOpts = array('type=', 'verbose'); $params = $cg->getopt2($args, $shortOpts, $longOpts); if (PEAR::isError($params)) { echo 'Error: ' . $params->getMessage() . "\n"; exit(1); } var_dump($params); ?>