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

 ID:                 60181
 Updated by:         paj...@php.net
 Reported by:        php at aldomx dot com
 Summary:            proc_open fails to read quoted whitespaced
                     directories in Windows
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Program Execution
 Operating System:   Windows 7
 PHP Version:        5.3.8
 Block user comment: N
 Private report:     N

 New Comment:

Have you tries to use escape shell args?


Previous Comments:
------------------------------------------------------------------------
[2011-10-31 22:51:41] php at aldomx dot com

Sorry, I forgot to specify "when you use 2 or more quoted arguments" (in my 
example git directory in program files and working directory)

------------------------------------------------------------------------
[2011-10-31 22:43:35] paj...@php.net

Works just fine:

<?php
$descriptorspec = array(
   1 => array("pipe", "w"),
   2 => array("pipe", "w")
);

$cmd = '"c:\\test\\bin with space\\t.bat"';
$process = proc_open($cmd, $descriptorspec, $pipes);
echo stream_get_contents($pipes[1]);
echo stream_get_contents($pipes[2]);

$return_value = proc_close($process);
echo "command returned $return_value\n";

where t.bat contains only "dir" for testing

------------------------------------------------------------------------
[2011-10-31 22:05:01] php at aldomx dot com

Description:
------------
Trying to execute via proc_open:

"C:/Program Files (x86)/Git/bin/git.exe" status --porcelain 
--untracked-files=all 
-- "D:/home/aldo/git/test whitespace"

is like not using them, since the result of STDERR is:

'C:/Program' is not recognized as an internal or external command,
operable program or batch file.

Test script:
---------------
<?php
$command = sprintf(
        '"%s" status --porcelain --untracked-files=all -- "%s"', // Git command
        'C:/Program Files (x86)/Git/bin/git.exe', // Git executable
        'D:/home/aldo/git/test with whitespace' // Directory
);
// $command = '"C:/Program Files (x86)/Git/bin/git.exe" status --porcelain 
--untracked-files=all -- "D:/home/aldo/git/test with whitespace"';

$proc = proc_open(
        $command,
        array (
                array ( "pipe", "r" ),
                array ( "pipe", "w" ),
                array ( "pipe", "w" )
        ),
        $pipes
);

echo stream_get_contents( $pipes[2] );
// Outputs: 'C:/Program' is not recognized as an internal or external command,
// operable program or batch file.
?>

Expected result:
----------------
proc_open read the quotes correctly and manages to run git-status smoothly

Actual result:
--------------
'C:/Program' is not recognized as an internal or external command,
operable program or batch file.


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



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

Reply via email to