diff --git a/getopts.php b/getopts.php index a3aa344..18cd6df 100644 --- a/getopts.php +++ b/getopts.php @@ -88,7 +88,7 @@ class getopts else $long = array (); } - if ($short[0] === ":") + if (substr ($short, 0, 1) !== false && $short[0] === ":") throw new \Exception ("Short option can't start by semi-colon", 500); if ((strpos ($short, ":") !== false || strpos (implode ($long), ":") !== false) && @@ -248,9 +248,10 @@ class getopts $token = "$prevToken$token"; $prevToken = ""; } - if ($this->restOfLine !== null) - $this->restOfLine[] = $token; - elseif (trim ($token) !== "") + //if ($this->restOfLine !== null) + // $this->restOfLine[] = $token; + //elseif (trim ($token) !== "") + if (trim ($token) !== "") $tokens[] = $token; $offset = $end + 1; } @@ -258,7 +259,7 @@ class getopts // Analyze the tokens to fill the $this->parameters if ($this->restOfLine === null) - $this->restOfLine = ""; + $this->restOfLine = array (); if (! array_key_exists (0, $tokens)) throw new \Exception ("Can not find the program name (\$argv[0]", 500); $this->programName = array_shift ($tokens); @@ -482,7 +483,7 @@ class getopts $paramOptional = false; if ($i > 0) $d .= ", "; - $d .= $option; + $d .= str_replace (":", "", $option); if ($param) { $d .= " ";