Zero exit code on option parsing failure

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