Permalink
Browse files

* fix Bug #11068: No way to read plain "-" option [cardoe]

git-svn-id: http://svn.php.net/repository/pear/packages/Console_Getopt/trunk@237494 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
Greg Beaver
Greg Beaver committed Jun 12, 2007
1 parent c904610 commit 5a2a0fcae27b1f82b58f80b4418361f5646afc4d
Showing with 67 additions and 4 deletions.
  1. +4 −0 Console/Getopt.php
  2. +44 −0 Console/tests/bug11068.phpt
  3. +19 −4 package.xml
View
@@ -127,6 +127,10 @@ function doGetopt($version, $args, $short_options, $long_options = null)
$error = Console_Getopt::_parseLongOption(substr($arg, 2), $long_options, $opts, $args);
if (PEAR::isError($error))
return $error;
+ } elseif ($arg == '-') {
+ // - is stdin
+ $non_opts = array_merge($non_opts, array_slice($args, $i));
+ break;
} else {
$error = Console_Getopt::_parseShortOption(substr($arg, 1), $short_options, $opts, $args);
if (PEAR::isError($error))
@@ -0,0 +1,44 @@
+--TEST--
+Console_Getopt [bug 11068]
+--SKIPIF--
+--FILE--
+<?php
+$_SERVER['argv'] =
+$argv = array('hi', '-fjjohnston@mail.com', '--to', 'hi', '-');
+require_once 'Console/Getopt.php';
+$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'f:t:',
+array('from=','to=','mailpack=','direction=','verbose','debug'));
+if(PEAR::isError($ret))
+{
+ echo $ret->getMessage()."\n";
+ echo 'FATAL';
+ exit;
+}
+
+print_r($ret);
+?>
+--EXPECT--
+Array
+(
+ [0] => Array
+ (
+ [0] => Array
+ (
+ [0] => f
+ [1] => jjohnston@mail.com
+ )
+
+ [1] => Array
+ (
+ [0] => --to
+ [1] => hi
+ )
+
+ )
+
+ [1] => Array
+ (
+ [0] => -
+ )
+
+)
View
@@ -27,9 +27,9 @@ short and long options.
<email>cellog@php.net</email>
<active>yes</active>
</helper>
- <date>2007-02-17</date>
+ <date>2007-06-12</date>
<version>
- <release>1.2.2</release>
+ <release>1.2.3</release>
<api>1.2.1</api>
</version>
<stability>
@@ -38,8 +38,7 @@ short and long options.
</stability>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
- * fix Bug #4475: An ambiguous error occurred when specifying similar longoption name.
- * fix Bug #10055: Not failing properly on short options missing required values
+ * fix Bug #11068: No way to read plain &quot;-&quot; option [cardoe]
</notes>
<contents>
<dir name="/">
@@ -66,6 +65,22 @@ short and long options.
</dependencies>
<phprelease />
<changelog>
+ <release>
+ <version>
+ <release>1.2.2</release>
+ <api>1.2.1</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <date>2007-02-17</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>
+ * fix Bug #4475: An ambiguous error occurred when specifying similar longoption name.
+ * fix Bug #10055: Not failing properly on short options missing required values
+ </notes>
+ </release>
<release>
<version>
<release>1.2.1</release>

0 comments on commit 5a2a0fc

Please sign in to comment.