Skip to content

Commit

Permalink
Using exec explicitly breaks CMD compat
Browse files Browse the repository at this point in the history
Using `exec` doesn't work on windows as exec is not a valid CMD command. This fixes silverstripe#11. 

Also a validation for directory separator was added to mantain *nix shells. (This is actually a Symphony's `Process` class related issue)
  • Loading branch information
tony13tv authored Nov 10, 2020
1 parent 2eb7516 commit 3f798a3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion code/ServerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ public function launchServer($options)
$port = PortChecker::findNextAvailablePort($host, $options['preferredPort']);

$base = __DIR__;
$command = "exec " . escapeshellcmd($bin) .
$command = escapeshellcmd($bin) .
' -S ' . escapeshellarg($host . ':' . $port) .
' -t ' . escapeshellarg($this->path) . ' ' .
escapeshellarg($base . '/server-handler.php');
if(\DIRECTORY_SEPARATOR !== '\\') {
$command = "exec ";
}

if (!empty($options['bootstrapFile'])) {
$command = "SERVE_BOOTSTRAP_FILE=" . escapeshellarg($options['bootstrapFile']) . " $command";
Expand Down

0 comments on commit 3f798a3

Please sign in to comment.