]> granicus.if.org Git - php/commitdiff
* stop parsing arguments when encoutering the first non-option arg
authorStig Bakken <ssb@php.net>
Mon, 10 Dec 2001 16:38:44 +0000 (16:38 +0000)
committerStig Bakken <ssb@php.net>
Mon, 10 Dec 2001 16:38:44 +0000 (16:38 +0000)
pear/Console/Getopt.php

index b20bc6754ac70394c203a1eb9d38df9791b8668c..b717f91045d2669c3dcc128fbbd737de36bc8434 100644 (file)
@@ -77,15 +77,18 @@ class Console_Getopt {
         reset($args);
         while (list($i, $arg) = each($args)) {
 
-            /* The special element '--' means explicit end of options. Treat the
-               rest of the arguments as non-options and end the loop. */
+            /* The special element '--' means explicit end of
+               options. Treat the rest of the arguments as non-options
+               and end the loop. */
             if ($arg == '--') {
                 $non_opts = array_merge($non_opts, array_slice($args, $i + 1));
                 break;
             }
 
             if ($arg{0} != '-' || (strlen($arg) > 1 && $arg{1} == '-' && !$long_options)) {
-                $non_opts[] = $arg;
+                //$non_opts[] = $arg;
+                $non_opts = array_merge($non_opts, array_slice($args, $i));
+                break;
             } else if (strlen($arg) > 1 && $arg{1} == '-') {
                 $error = Console_Getopt::_parseLongOption(substr($arg, 2), $long_options, $opts, $args);
                 if (PEAR::isError($error))