Edit report at https://bugs.php.net/bug.php?id=43908&edit=1

 ID:                 43908
 Updated by:         ras...@php.net
 Reported by:        Arne dot Heizmann at csr dot com
 Summary:            Add an optional parameter to exec() to not trim
                     whitespace from output
 Status:             Wont fix
 Type:               Feature/Change Request
 Package:            *General Issues
 Operating System:   Windows 2000
 PHP Version:        5.2.5
 Block user comment: N
 Private report:     N

 New Comment:

If you want full control, use proc_open/proc_close. proc_close() will give you 
the exit code or you can write $? to one of the streams to get a more accurate 
one. I suppose you could also do something intelligent with $? on the 
shell_exec() command, but that is more of a hack. All these exec() functions 
simply apply different levels of filtering and usability on top of the 
low-level 
proc_open() call. If it isn't doing what you want drop down a level and 
implement 
what you need. There are plenty of cases where you want \r\n and all other 
whitespace stripped from the end of lines.


Previous Comments:
------------------------------------------------------------------------
[2012-12-12 23:30:48] dwake at box dot com

With regard to the need for a delimiter, I guess that, like Arne, I'm wondering 
why we couldn't just use the newline character for that purpose.

------------------------------------------------------------------------
[2012-12-12 23:24:38] dwake at box dot com

If I use shell_exec(), is there any way to get the exit code?

------------------------------------------------------------------------
[2012-12-12 23:18:52] ras...@php.net

If you want the raw unaltered output from the command use shell_exec() not 
exec(). By definition exec() has to use a delimiter in order to create the 
array. 
If you don't want it to do that, just grab the raw via shell_exec() and do your 
own parsing.

------------------------------------------------------------------------
[2012-12-12 23:08:08] dwake at box dot com

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.

------------------------------------------------------------------------
[2008-07-18 16:02:08] j...@php.net

Reclassified.

------------------------------------------------------------------------


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

Reply via email to