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

Bug #2601 Parameter with minus as "a-minus"
Submitted: 2004-10-23 17:31 UTC
From: toggg Assigned: scottmattocks
Status: Closed Package: Console_Getargs
PHP Version: Irrelevant OS: FC2
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 : 18 - 15 = ?

 
 [2004-10-23 17:31 UTC] toggg
Description: ------------ Hello again ! $>pear ... upgrade-all ok: Console_Getargs 1.2.0 I have downloaded example.php from CVS (1.7) ---------> If I run: [...]$ php -q example.php para ... Parameters: para ---------> Everything OK ---------> But if I run: [...]$ php -q example.php p-ra ... ERROR! ... Unknown argument ra ---------> Test on both '--' not only the 2nd one ! Regards. bertrand. Reproduce code: --------------- // diff Getargs.php Getargs-minus.php 634c634 < if (strlen($arg) > 1 && $arg{1} == '-') { --- > if (preg_match('/--.+/', $arg)) { 893c893 < if (strlen($arg) > 1 && $arg{1} == '-' || --- > if (preg_match('/--.+/', $arg) ||

Comments

 [2004-10-23 19:49 UTC] toggg
I missed summary again ??? sorry, bertrand Gugger
 [2004-10-23 22:31 UTC] bmansion at mamasam dot com
if (strlen($arg) > 1 && $arg{0} == '-' && $arg{1} == '-') { is probably faster than a regex and does not require PCRE.
 [2004-10-24 09:43 UTC] toggg
>>if (strlen($arg) > 1 && $arg{0} == '-' && $arg{1} == '-') { >>is probably faster than a regex and does not require PCRE. You're right, but quickness is not in question ! (or we need to talk from other stuff in Getargs)
 [2004-10-24 10:31 UTC] wenz
>>is probably faster than a regex and does not require PCRE. >You're right, but quickness is not in question ! yes, but not adding a new dependency to a stable package is the way to go :-)
 [2004-10-24 11:17 UTC] toggg
>>>is probably faster than a regex and does not require PCRE. >>You're right, but quickness is not in question ! >yes, but not adding a new dependency to a stable package is the way to go :-) Does it? Do you mean: If the php script never ask some regexp stuff, then this PHP extension is not loaded ? I'm not understanding the sense of not doing regexp Sure you mean it's better to glue PHP's kernel, should be best, I agree. regexp not in the kernel ? OK, here, we don't need it. >>> if (strlen($arg) > 1 && $arg{0} == '-' && $arg{1} == '-') { is absolutly right ! (faster and more understandable)
 [2004-11-01 21:49 UTC] scottmattocks
Fixed. The arg{0} == '-' check was actually needed in two places, where you guys noted and in the isValue() method. The fix will be added to the next release (1.2.1)