Edit report at https://bugs.php.net/bug.php?id=43908&edit=1
ID: 43908
Comment by: dwake at box dot com
Reported by: Arne dot Heizmann at csr dot com
Summary: Add an optional parameter to exec() to not trim
whitespace from output
Status: Open
Type: Feature/Change Request
Package: Feature/Change Request
Operating System: Windows 2000
PHP Version: 5.2.5
Block user comment: N
Private report: N
New Comment:
I've just run into this "feature", writing a tool that needs to be able to read
in a file from a given commit repo. Because of the "feature", every line in
the resulting file is stripped of trailing whitespace, creating a lot of
spurious diffs.
I am at a loss to see the motivation for this behavior. Information is being
discarded, with no possibility of recovering it. The only workaround I can
think of is to
1. Use sed, or a comparable utility, to add a non-whitespace character to the
end of every line
2. Make the PHP exec() call
3. In PHP, strip the spurious character from the end of each line.
Please put in the extra flag to turn this behavior off.
Previous Comments:
------------------------------------------------------------------------
[2008-07-18 16:02:08] [email protected]
Reclassified.
------------------------------------------------------------------------
[2008-07-18 14:28:05] Arne dot Heizmann at csr dot com
This is most certainly not expected behaviour, and furthermore, it is dataloss.
If you must preserve backwards compatibility, which is certainly fair, then I
recommend you add a new boolean option to the exec() call to preserve the
whitespace. Either way, this bug is not bogus.
I have an application whose output may or may not contain lines that contain
only whitespace. I need for this whitespace to be preserved as otherwise I
cannot parse the output correctly.
Please note that I'm not talking about the trailing "\n" which is mentioned in
the documentation. I'm referring to all other whitespace, especially spaces and
tabs.
------------------------------------------------------------------------
[2008-07-17 23:43:21] [email protected]
Expected behaviour and can not be changed. RTFM: http://php.net/exec
------------------------------------------------------------------------
[2008-06-02 13:26:52] Arne dot Heizmann at csr dot com
Could we have this fix in the next version please? Just remove all the code
that removes the whitespace?
------------------------------------------------------------------------
[2008-01-25 18:24:43] [email protected]
Because that is intentional, however, it affect results as your case, when the
string is consisting entirely of whitespace.
Well, anyway, maybe this isn't a good idea, it was only my idea.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=43908
--
Edit this bug report at https://bugs.php.net/bug.php?id=43908&edit=1