|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-10-31 22:05 UTC] 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. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 00:00:02 2025 UTC |
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 testingWorkaround: use array('bypass_shell' => TRUE) as last argument.I tried the workaround of adding "array('bypass_shell' => TRUE)" as a parameter. While it eliminates the error message, the command still does not execute. This still looks like a bug to me.