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: 2021-02-11 15:46 UTC
From: yunosh@php.net 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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: yunosh@php.net
New email:
PHP Version: OS:

 

 [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

Pull Requests

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.
 [2021-02-11 11:54 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-02-11 11:54 UTC] cmb@php.net
Does this still happen with any of the actively supported PHP
versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2021-02-11 14:43 UTC] yunosh@php.net
Unfortunately 3v4l.org doesn't support exec(), so it's hard to test.
 [2021-02-11 15:46 UTC] cmb@php.net
-Status: Feedback +Status: Closed
 [2021-02-11 15:46 UTC] cmb@php.net
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: Sat Dec 21 12:01:31 2024 UTC