From 3f798a346b56140d4f19f4d40f49e494b468d838 Mon Sep 17 00:00:00 2001 From: Cristian Torres Date: Mon, 9 Nov 2020 22:31:30 -0600 Subject: [PATCH] Using exec explicitly breaks CMD compat Using `exec` doesn't work on windows as exec is not a valid CMD command. This fixes #11. Also a validation for directory separator was added to mantain *nix shells. (This is actually a Symphony's `Process` class related issue) --- code/ServerFactory.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/ServerFactory.php b/code/ServerFactory.php index 25137b4..d6eb845 100644 --- a/code/ServerFactory.php +++ b/code/ServerFactory.php @@ -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";