|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68977 Regression with linebreaks returned from exec()
Submitted: 2015-02-03 10:36 UTC Modified: 2021-02-11 15:46 UTC
From: Assigned: cmb (profile)
Status: Closed Package: Program Execution
PHP Version: 5.4Git-2015-02-03 (Git) 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.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2015-02-03 10:36 UTC]
exec() doesn't return empty lines from execution results as empty strings, but as newline characters.

Test script:

#!/usr/bin/env php
Line one
Line two

Line three
Line four


exec(__DIR__ . '/cmd.php', $result, $value);

Expected result:
array(5) {
  string(8) "Line one"
  string(8) "Line two"
  string(0) ""
  string(10) "Line three"
  string(9) "Line four"

Actual result:
array(5) {
  string(8) "Line one"
  string(8) "Line two"
  string(1) "
  string(10) "Line three"
  string(9) "Line four"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-03 10:52 UTC]
I think I've seen the same issue for release version.
It would be nicer add this to the bug report.
 [2015-02-03 11:55 UTC]
I tried with 5.6 from rasmus' vagrant box, and the bug wasn't there.
 [2021-02-11 11:54 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-02-11 11:54 UTC]
Does this still happen with any of the actively supported PHP

[1] <>
 [2021-02-11 14:43 UTC]
Unfortunately doesn't support exec(), so it's hard to test.
 [2021-02-11 15:46 UTC]
-Status: Feedback +Status: Closed
 [2021-02-11 15:46 UTC]
I cannot reproduce this with PHP 7.4 on Linux, so I'm assuming
it has been fixed.  On Windows, this certainly never has been
an issue.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 28 22:01:27 2024 UTC