diff --git a/bin/composer b/bin/composer index 823f87a4b442..88566e17014e 100755 --- a/bin/composer +++ b/bin/composer @@ -48,6 +48,8 @@ if (function_exists('ini_set')) { unset($memoryInBytes, $memoryLimit); } +putenv('COMPOSER_BINARY='.realpath($_SERVER['argv'][0])); + // run the command application $application = new Application(); $application->run(null, $output); diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index e6cc378a09b5..fdb00866801e 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -180,7 +180,7 @@ protected function doDispatch(Event $event) if (!$phpPath) { throw new \RuntimeException('Failed to locate PHP binary to execute '.$scriptName); } - $exec = $phpPath . ' ' . realpath($_SERVER['argv'][0]) . substr($callable, 9); + $exec = ProcessExecutor::escape($phpPath) . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($callable, 9); if (0 !== ($exitCode = $this->process->execute($exec))) { $this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName()));