ZF-5345: using '-' as argument on cli call raise Zend_Console_Getopt_Exception("Option \"\" is not recognized.")
Description
If we make a cli call to a php script without using options and using '-' as argument, Zend_Console_Getopt raise a Zend_Console_Getopt_Exception("Option \"\" is not recognized.") exception.
ex: ```
This is very annoying because it's a standard to use '-' as argument to tell to the script to look at STDIN to get its input.
Regards, Remy Damour
Comments
Posted by Remy Damour (remy215) on 2008-12-23T09:54:33.000+0000
as a quick fix, I extended this class, overloading _parseSingleOption method as described below:
Posted by Remy Damour (remy215) on 2008-12-23T10:09:09.000+0000
Fix on my quick fix :-) (I should have tested first): my quick fix does not generate any error, but ignores "-" as a remainingArgument, considering it as an option flag: $this->getRemainingArgs() returns an empty array instead of array("-");
The fix below solves all problems (i've highlighted my change). I no longer overload _parseSingleOption() method, but parse() method instead:
change made is on last "else if" statement: } else if ({color:green}'-' != $argv[0] && {color}substr($argv[0], 0, 1) == '-') {
Posted by Benjamin Eberlei (beberlei) on 2009-01-09T06:38:59.000+0000
Fixed in next version.
Posted by Benjamin Eberlei (beberlei) on 2009-01-14T13:14:15.000+0000
merged back into 1.7 release branch, due to possible 1.7.3 release