php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23476 Console::Getopt: Long option ==0 not detected
Submitted: 2003-05-04 07:14 UTC Modified: 2003-07-28 05:00 UTC
From: vonderheide at redlink dot de Assigned:
Status: Closed Package: PEAR related
PHP Version: 4.3.2RC2 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vonderheide at redlink dot de
New email:
PHP Version: OS:

 

 [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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-06 09:45 UTC] arnaud@php.net
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");
                     }
                 }
 [2003-06-30 05:23 UTC] cox@php.net
This bug has been fixed in CVS, thanks (see bug #21994)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jun 02 17:01:26 2025 UTC