php.net |  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: 2015-02-03 11:55 UTC
From: yunosh@php.net Assigned:
Status: Open Package: Program Execution
PHP Version: 5.4Git-2015-02-03 (Git) OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

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

Test script:
---------------
cmd.php:

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

Line three
Line four

test.php:

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


Expected result:
----------------
array(5) {
  [0]=>
  string(8) "Line one"
  [1]=>
  string(8) "Line two"
  [2]=>
  string(0) ""
  [3]=>
  string(10) "Line three"
  [4]=>
  string(9) "Line four"
}


Actual result:
--------------
array(5) {
  [0]=>
  string(8) "Line one"
  [1]=>
  string(8) "Line two"
  [2]=>
  string(1) "
"
  [3]=>
  string(10) "Line three"
  [4]=>
  string(9) "Line four"
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-03 10:52 UTC] yohgaki@php.net
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] yunosh@php.net
I tried with 5.6 from rasmus' vagrant box, and the bug wasn't there.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Nov 15 17:01:42 2019 UTC