From e456347ffea5ee15fba229525f22a96b78865455 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 24 Oct 2016 15:21:16 +0200 Subject: $noopts should not affect fetching of named parameters --- it.class | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/it.class b/it.class index 45903b5..42808ad 100644 --- a/it.class +++ b/it.class @@ -795,9 +795,7 @@ static function getopt($usage, $p = array()) foreach (array_slice($_SERVER['argv'], 1) as $arg) { - if ($noopts) - $result['args'][] = $seenarg = $arg; - else if ($eat) + if ($eat) { if (it::match('^--?\w', $arg)) # Already next option => Missing argument? $err = true; @@ -806,7 +804,7 @@ static function getopt($usage, $p = array()) } else if ($arg == "--") $noopts = true; - elseif ($matches = (array)it::match('^--(\w[\w-]*)(=.*)?', $arg)) + elseif (!$noopts && ($matches = (array)it::match('^--(\w[\w-]*)(=.*)?', $arg))) { list($optname, $val) = $matches; if (!isset($witharg[$optname]) || isset($val) && !$witharg[$optname]) @@ -816,7 +814,7 @@ static function getopt($usage, $p = array()) else $result[$optname] = $val ? substr($val, 1) : true; } - else if (($letters = it::match('^-(\w+)', $arg)) || $letters === "0") + else if (!$noopts && (($letters = it::match('^-(\w+)', $arg)) || $letters === "0")) { foreach (explode("\n", trim(chunk_split($letters, 1, "\n"))) as $letter) { -- cgit v1.2.3