|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-05-04 07:14 UTC] vonderheide at redlink dot de
When giving a long option as 0 (as in --offset=0), Getopt raises a "Console_Getopt: option --$opt requires an argument" error.
The bug is in line 186 (current CVS):
if (!$opt_arg && !(list(, $opt_arg) = each($args))) {
This can be fixed by replacing
!$opt_arg
with
$opt_arg !== ''
although I haven't checked if this has any side effects.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 10:00:01 2025 UTC |
The following patch would do the job. Can somebody with enough GetOpt knowledge please review this patch. From my little experience it looks ok. --- Getopt.php 2003-05-06 16:43:51.000000000 +0200 +++ ../../../../tmp/php4-win32-STABLE-200305060030/PEAR/Console/Getopt.php 2003-05-06 16:42:28.000000000 +0200 @@ -3,7 +3,7 @@ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | +// | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ // | Author: Andrei Zmievski <andrei@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Getopt.php,v 1.21 2002/08/05 12:58:38 alan_k Exp $ +// $Id: Getopt.php,v 1.22 2002/12/31 16:18:25 sebastian Exp $ require_once 'PEAR.php'; @@ -183,7 +183,7 @@ if (substr($long_opt, -2) != '==') { /* Long option requires an argument. Take the next argument if one wasn't specified. */; - if (!$opt_arg && !(list(, $opt_arg) = each($args))) { + if ($opt_arg !== '' && !(list(, $opt_arg) = each($args))) { return PEAR::raiseError("Console_Getopt: option --$opt requires an argument"); } }