For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > July 2005 > #33790 [Ver->Opn]: Exec command trims spaces from output









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #33790 [Ver->Opn]: Exec command trims spaces from output
sniper@php.net

2005-07-29, 10:00 pm

ID: 33790
Updated by: sniper@php.net
Reported By: marcus at names dot co dot uk
-Status: Verified
+Status: Open
-Bug Type: Program Execution
+Bug Type: Documentation problem
Operating System: *
PHP Version: 5CVS, 4CVS (2005-07-20)
New Comment:

The manual should state this fact. There is no bug to fix as these
functions have worked like this since PHP 3.

You can use ob_start()..passthru()..ob_get_contents() as workaround. Or
you can use glob() or scandir() if you only need to get the filenames..



Previous Comments:
------------------------------------------------------------------------

[2005-07-20 17:13:36] marcus at names dot co dot uk

Description should read, "all white space
is removed FROM THE END OF EACH LINE, rather than just
new line characters".

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

[2005-07-20 17:11:10] marcus at names dot co dot uk

Description:
------------
Each line in the output array returned as the second
parameter of exec() is trimmed so that all white space
is removed, rather than just new line characters.

I found this issue while trying to use the following
command to find all files in the current directory whose
name ends in a space:

exec("find . -name '* '",$output_array,$status);

However, in $output_array the filenames have been
trimmed so that they no longer end in a space.

Reproduce code:
---------------
exec("find . -name '* '",$output_array,$status);

Expected result:
----------------
array(
"file1 "
"file2 "
);

Actual result:
--------------
array(
"file1"
"file2"
);


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


--
Edit this bug report at http://bugs.php.net/?id=33790&edit=1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com