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

Bug #10055 Not failing properly on short options missing required values
Submitted: 2007-02-08 17:43 UTC
From: jjohnston at mailwise dot com Assigned: cellog
Status: Closed Package: Console_Getopt (version 1.2.1)
PHP Version: 4.4.4 OS: SuSE 9.2
Roadmaps: (Not assigned)    
Subscription  


 [2007-02-08 17:43 UTC] jjohnston at mailwise dot com (Joshua Johnston)
Description: ------------ Depending on the order that command line options are passed, it is possible to 'bypass' a required value for a short option which erroneously assigns another option as the value to the previous option. Test script: --------------- <?php // filename test.php require_once 'Console/Getopt.php'; $options = new Console_Getopt(); $ret = $options->getopt($options->readPHPArgv(), 'i:r::l', array('file=','test==')); if(PEAR::isError($ret)) { die($ret->getMessage()."\n"); } else { var_dump($ret); } ?> Correct results $ php test.php -l -i Incorrect results $ php test.php -i -l Expected result: ---------------- $ php test.php -l -i # Behaves correctly $ php test.php -i -l Console_Getopt: option requires an argument -- i Because -i is missing its value and -l is a different option. Actual result: -------------- # Incorrect behavior $ php test.php -i -l array(2) { [0]=> array(1) { [0]=> array(2) { [0]=> string(1) "i" [1]=> string(2) "-l" } } [1]=> array(0) { } } # Correct behavior $ php test.php -l -i Console_Getopt: option requires an argument -- i

Comments

 [2007-02-18 04:13 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!