php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52496 Zero exit code on option parsing failure
Submitted: 2010-07-30 08:36 UTC Modified: 2011-05-30 17:58 UTC
From: php-bugs at thequod dot de Assigned: iliaa (profile)
Status: Closed Package: CGI/CLI related
PHP Version: 5.3.3 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php-bugs at thequod dot de
New email:
PHP Version: OS:

 

 [2010-07-30 08:36 UTC] php-bugs at thequod dot de
Description:
------------
When PHP's option parsing fails, PHP outputs the "Usage" info, but exits with exit code 0, which means "success".

So, given any PHP script where the options in the shebang line are wrong, or only considered wrong (like with bug 52495), will never execute, but always report success!

Please fix this, so that option parsing will return a non-exit error code.

Test script:
---------------
# php --wrong-option ; echo $?

Expected result:
----------------
# php --wrong-option ; echo $?
Usage: php [options] [-f] <file> [--] [args...]
[...]

1

Actual result:
--------------
# php --wrong-option ; echo $?
Usage: php [options] [-f] <file> [--] [args...]
[...]

0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-30 17:57 UTC] iliaa@php.net
Automatic comment from SVN on behalf of iliaa
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=311600
Log: Fixed bug #52496 (Zero exit code on option parsing failure).
 [2011-05-30 17:58 UTC] iliaa@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: iliaa
 [2011-05-30 17:58 UTC] iliaa@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2012-04-18 09:50 UTC] laruence@php.net
Automatic comment on behalf of iliaa
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7acafb506a652cc08728e8fdab73c1e06d4bf006
Log: Fixed bug #52496 (Zero exit code on option parsing failure).
 [2012-07-24 23:41 UTC] rasmus@php.net
Automatic comment on behalf of iliaa
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7acafb506a652cc08728e8fdab73c1e06d4bf006
Log: Fixed bug #52496 (Zero exit code on option parsing failure).
 [2013-11-17 09:38 UTC] laruence@php.net
Automatic comment on behalf of iliaa
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7acafb506a652cc08728e8fdab73c1e06d4bf006
Log: Fixed bug #52496 (Zero exit code on option parsing failure).
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu May 28 11:01:28 2020 UTC