php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #18027 exit(0) in command-line use produces 255
Submitted: 2002-06-27 17:26 UTC Modified: 2002-06-27 17:30 UTC
From: befletch at yahoo dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.2.1 OS: OpenBSD 3.1
Private report: No CVE-ID: None
 [2002-06-27 17:26 UTC] befletch at yahoo dot com
Consider the following command line script:

#!/usr/local/bin/php -q
<?php

exit( 0 );

?>

With PHP 4.1.2, this returned 0 to the calling
process (e.g. the $? shell variable).  With
PHP 4.2.1, this no longer works - exit(0) returns
255.

I don't know if this is intentional or not, but
now the only way I can use 0 for success and !0
for errors is:

$return_val = whatever();

if ( $return_val === 0 )
  return 0;
else
  exit( $return_val );

Can this be returned to the older way of doing
things?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-27 17:30 UTC] derick@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 09:01:28 2024 UTC