* @access public
*
*/
+ function getopt2($args, $short_options, $long_options = null)
+ {
+ return Console_Getopt::doGetopt(2, $args, $short_options, $long_options);
+ }
+
+ /**
+ * This function expects $args to start with the script name (POSIX-style).
+ * Preserved for backwards compatibility.
+ * @see getopt2()
+ */
function getopt($args, $short_options, $long_options = null)
+ {
+ return Console_Getopt::doGetopt(1, $args, $short_options, $long_options);
+ }
+
+ /**
+ * The actual implementation of the argument parsing code.
+ */
+ function doGetopt($version, $args, $short_options, $long_options = null)
{
// in case you pass directly readPHPArgv() as the first arg
if (PEAR::isError($args)) {
sort($long_options);
}
+ /*
+ * Preserve backwards compatibility with callers that relied on
+ * erroneous POSIX fix.
+ */
+ if ($version < 2) {
+ if (isset($args[0]{0}) && $args[0]{0} != '-') {
+ array_shift($args);
+ }
+ }
+
reset($args);
while (list($i, $arg) = each($args)) {
</maintainer>
</maintainers>
<release>
- <version>2.0</version>
- <date>2003-12-06</date>
- <notes>Revert of erroneous POSIX compatibility fix (BC break)</notes>
+ <version>1.2</version>
+ <date>2003-12-11</date>
+ <notes>Fix to preserve BC with 1.0 and allow correct behaviour for new users</notes>
<state>stable</state>
<filelist>
<dir name="Console">
</release>
<changelog>
<release>
- <version>0.11</version>
- <date>2002-05-26</date>
- <notes>POSIX getopt compatibility fix: treat first element of args
- array as command name
- </notes>
- <state>beta</state>
+ <version>1.0</version>
+ <date>2002-09-13</date>
+ <notes>Stable release</notes>
+ <state>stable</state>
<filelist>
<dir name="Console">
<file role="php" name="Getopt.php"/>
</dir>
</filelist>
</release>
- <release>
- <version>0.10</version>
- <date>2002-05-12</date>
- <notes>Packaging fix</notes>
- <state>beta</state>
- </release>
- <release>
- <version>0.9</version>
- <date>2002-05-12</date>
- <notes>Initial release</notes>
- <state>beta</state>
- </release>
+ <release>
+ <version>0.11</version>
+ <date>2002-05-26</date>
+ <notes>POSIX getopt compatibility fix: treat first element of args
+ array as command name
+ </notes>
+ <state>beta</state>
+ <filelist>
+ <dir name="Console">
+ <file role="php" name="Getopt.php"/>
+ </dir>
+ </filelist>
+ </release>
+ <release>
+ <version>0.10</version>
+ <date>2002-05-12</date>
+ <notes>Packaging fix</notes>
+ <state>beta</state>
+ </release>
+ <release>
+ <version>0.9</version>
+ <date>2002-05-12</date>
+ <notes>Initial release</notes>
+ <state>beta</state>
+ </release>
</changelog>
-</package>
+ </package>