Doc #65925 [Opn->Csd]: Incorrect return value for shell_exec(), backticks

From: Date: Tue, 22 Oct 2013 12:05:03 +0000
Subject: Doc #65925 [Opn->Csd]: Incorrect return value for shell_exec(), backticks
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-10522@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65925&edit=1 ID: 65925 Updated by: daverandom@php.net Reported by: krewecherl at gmail dot com Summary: Incorrect return value for shell_exec(), backticks -Status: Open +Status: Closed Type: Documentation Problem Package: Documentation problem PHP Version: Irrelevant -Assigned To: +Assigned To: daverandom Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2013-10-22 12:04:16] daverandom@php.net Automatic comment from SVN on behalf of daverandom Revision: http://svn.php.net/viewvc/?view=revision&revision=331914 Log: Note that shell_exec() also returns NULL when the executed command produces no output. Fixes bug #65925. ------------------------------------------------------------------------ [2013-10-18 00:36:25] krewecherl at gmail dot com Description: ------------ The page at http://www.php.net/manual/en/function.shell-exec.php reads: Return Values The output from the executed command or NULL if an error occurred. This is incorrect, as some of the commenters have noted. Successfully executed commands (exit status 0) that produce no output also return NULL. The return value is documented to be a string, so we would expect an empty string in the case of no output. I would even argue that this is a bug, because it prevents detecting a non-zero exit status, but changing the behavior at this late stage would probably do more damage than good. In any case, it needs to be properly documented. Test script: --------------- $ php -r 'system("sync", $status); var_dump($status);' int(0) $ php -r '$rv = shell_exec("sync"); var_dump($rv);' NULL $ php -r '$rv = sync; var_dump($rv);' NULL ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65925&edit=1

« previous php.doc.bugs (#10522) next »