php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11008 exit() should return an exit status if passed, not send to stdout
Submitted: 2001-05-21 21:34 UTC Modified: 2002-01-06 08:50 UTC
From: brianm at dealnews dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Latest CVS (2001-05-21) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
30 - 23 = ?
Subscribe to this entry?

 
 [2001-05-21 21:34 UTC] brianm at dealnews dot com
Working with a shell script here.  I hoped that exit() would work like perl and return the passed status as and exist status.  As it stands now, it sends it to stdout.  This is unexpected.

It would be much more useful if exit() could be used to enable the use of PHP in shell scripts by returning the passed value as an exit status.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-22 01:59 UTC] bbonev@php.net
indeed it does both:

if php; then echo yes; fi
<? exit(0) ?>
X-Powered-By: PHP/4.0.5
Content-type: text/html

0yes

if php; then echo yes; fi
<? exit(1) ?>
X-Powered-By: PHP/4.0.5
Content-type: text/html

1

i don't see a real reason for the echoed exit status though
 [2001-05-23 11:24 UTC] brianlmoon@php.net
Anyone in the Zend core want to comment on this?  I know where the code is that does it.  But it is in the Zend code.

Is there a good reason to put this exit status to stdout?
 [2001-07-15 16:43 UTC] zeev@php.net
Simply put - no, it should not.

exit's optional argument is a termination message, not a shell status.
 [2001-12-06 17:02 UTC] sniper@php.net
I just got bitten by this. The manual page says that if the value passed
to exit() is integer it is used as exit status.

Or is there some other way to exit from PHP script with an exit status?

--Jani

 [2002-01-06 08:50 UTC] mfischer@php.net
Fixed in CVS (integer values aren't printed to stdout anymore).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC