php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80757 Exit code is 0 when could not open file
Submitted: 2021-02-16 16:07 UTC Modified: -
From: minterior at gmail dot com Assigned:
Status: Closed Package: phpdbg
PHP Version: Irrelevant 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: minterior at gmail dot com
New email:
PHP Version: OS:

 

 [2021-02-16 16:07 UTC] minterior at gmail dot com
Description:
------------
Tested in PHP versions 8.0.2 and 7.4.3.

When phpdbg can not open the given file it fails with the messages:
[Could not open file /missing_file]
[Failed to compile /missing_file, cannot run]

But the exit code is 0, when it should not.

On another hand, when the PHP file exists but has syntax errors it fails with:
[PHP Parse error:  syntax error, unexpected '!', expecting ';' or ',' in /invalid.php on line 3]

If it throws an exception:
[Uncaught Exception in /throw-exception.php on line 3]
Exception: I'm an exception thrown in /throw-exception.php:3
Stack trace:
#0 {main}

In both cases, the exit code is then 255 as expected.

Test script:
---------------
# Tested without Docker in Kubuntu Linux 20.04.2 LTS
phpdbg -qrr missing_file; echo $?
[Could not open file /missing_file]
[Failed to compile /missing_file, cannot run]
0

# Tested in Alpine Linux using Docker
docker run --rm --tty php:cli-alpine phpdbg -qrr missing_file; echo $?
[Could not open file /missing_file]
[Failed to compile /missing_file, cannot run]
0

Expected result:
----------------
A non-zero exit code is expected.

Actual result:
--------------
The exit code is 0.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-24 18:51 UTC] felipe@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3ec37a74a27261193155228081ec1bf6df35868e
Log: Fix bug #80757 (Exit code is 0 when could not open file)
 [2021-02-24 18:51 UTC] felipe@php.net
-Status: Open +Status: Closed
 [2021-02-24 19:08 UTC] felipe@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3ec37a74a27261193155228081ec1bf6df35868e
Log: Fix bug #80757 (Exit code is 0 when could not open file)
 [2021-02-24 20:31 UTC] nikic@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3ec37a74a27261193155228081ec1bf6df35868e
Log: Fix bug #80757 (Exit code is 0 when could not open file)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC