title: Weird bug in PHP, Spaces in Paths and Windows
body: <p>I've got to fix this little bug. First, let's talk about a small fact:
  In CLI on Windows, you can't run a program with a space in its path, unless escaped:</p>
  
  <pre><code>C:\&gt;a b/c.bat
  'a' is not recognized as an internal or external command,
  operable program or batch file.
  
  C:\&gt;"a b/c.bat"
  
  C:\&gt;
  </code></pre>
  
  <p>I'm using proc_open...proc_close in PHP to run a process (program), example:</p>
  
  <pre><code>function _pipeExec($cmd,$input=''){
      $proc=proc_open($cmd,array(0=&gt;array('pipe','r'),
          1=&gt;array('pipe','w'),2=&gt;array('pipe','w')),$pipes);
      fwrite($pipes[0],$input);
      fclose($pipes[0]);
      $stdout=stream_get_contents($pipes[1]); // max execusion time exceeded ssue
      fclose($pipes[1]);
      $stderr=stream_get_contents($pipes[2]);
      fclose($pipes[2]);
      $rtn=proc_close($proc);
      return array(
          'stdout'=&gt;$stdout,
          'stderr'=&gt;$stderr,
          'return'=&gt;(int)$rtn
      );
  }
  
  // example 1
  _pipeExec('C:\\a b\\c.bat -switch');
  // example 2
  _pipeExec('"C:\\a b\\c.bat" -switch');
  // example 3 (sounds stupid but I had to try)
  _pipeExec('""C:\\a b\\c.bat"" -switch');
  </code></pre>
  
  <p><strong>Example 1</strong></p>
  
  <ul>
  <li>RESULT:  1</li>
  <li>STDERR:  'C:\a' is not recognized as an internal or external command,
  operable program or batch file.</li>
  <li>STDOUT:</li>
  </ul>
  
  <p><strong>Example 2</strong></p>
  
  <ul>
  <li>RESULT:  1</li>
  <li>STDERR:  'C:\a' is not recognized as an internal or external command,
  operable program or batch file.</li>
  <li>STDOUT:</li>
  </ul>
  
  <p><strong>Example 3</strong></p>
  
  <ul>
  <li>RESULT:  1</li>
  <li>STDERR:  The filename, directory name, or volume label syntax is incorrect.</li>
  <li>STDOUT:</li>
  </ul>
  
  <p>So you see, either case (double quotes or not) the code fails.
  Is it me or am I missing something?</p>