Command execution on Windows breaks with special chars in path
Currently, FLOW3 has problems executing shell commands on Windows when the php binary path contains special characters such as backslash, whitespace or round brackets.
Steps to reproduce
Setup FLOW3 on a windows machine (here using ZendServer CE on Windows7 x64) having PHP binary in a folder that contains whitespaces or other special characters.
Configure php binary path in Settings.yaml like this:
core: phpBinaryPathAndFilename: 'C:\Program Files (x86)\Zend\ZendServer\bin\php.exe'
The correct escaped path should be:
"C:\Program Files (x86)\Zend\ZendServer\bin\php.exe"
escapeshellcmd() escapes the path as:
C:^\Program Files ^(x86^)^\Zend^\ZendServer^\bin^\php.exe
This leads to error messages like the following (in German, but the problem should be clear) when executing flow3 shell commands (e.g. "flow3 routing:list")
Der Befehl "C:\^Program" ist entweder falsch geschrieben oder konnte nicht gefunden werden.
and prevents the cache compilation to work automatically in Development context.
The correct escaping is achieved by replacing the escapeshellcmd call by escapeshellarg for Windows OSes.
The attached patch wraps this choice in a new protected function escapeShellCmd inside TYPO3\FLOW3\Core\Bootstrap.
Updated by Alexander Berl over 9 years ago
Sorry to re-post this bug, but it seems to have reappeared (or wasn't really fixed yet). I did some more testing with windows command line escaping and found the problem is actually within the escapeshellcmd logic or within windows logic if you want, which requires escaping of special chars ONLY if the string is not quoted (which it must be if it contains whitespaces).
I also posted a comment to the according PHP bug with further information:
For the time being I just replaced escapeshellcmd with escapeshellarg and removed the manual quoting.