Bug #60181 [Opn]: proc_open fails to read quoted whitespaced directories in Windows

From: Date: Mon, 31 Oct 2011 22:43:36 +0000
Subject: Bug #60181 [Opn]: proc_open fails to read quoted whitespaced directories in Windows
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-164745@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60181&edit=1

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

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[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


Thread (13 messages)

« previous php.bugs (#164745) next »