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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC