Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quotes around path in case of spaces. #310

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crunz
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ if ($autoloadFileFound === false) {
);
}

$application = new Crunz\Application('Crunz Command Line Interface', 'v2.2.0');
$application = new Crunz\Application('Crunz Command Line Interface', 'v2.3.x-dev');
$application->run();
8 changes: 6 additions & 2 deletions src/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -1110,8 +1110,12 @@ protected function serializeClosure(Closure $closure)
$closure = (new OpisClosureSerializer())->serialize($closure);
$serializedClosure = \http_build_query([$closure]);
$crunzRoot = CRUNZ_BIN;

return PHP_BINARY . " {$crunzRoot} closure:run {$serializedClosure}";
$phpBin = PHP_BINARY;
if (DIRECTORY_SEPARATOR === '\\') {
// For Windows, add quotes around path in case of spaces.
$phpBin = '"'.$phpBin.'"';
}
return "{$phpBin} {$crunzRoot} closure:run {$serializedClosure}";
}

/**
Expand Down
9 changes: 7 additions & 2 deletions tests/Unit/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,12 @@ public function closureCommandHaveFullBinaryPaths(): void
if (!\defined('CRUNZ_BIN')) {
\define('CRUNZ_BIN', __FILE__);
}


$phpBin = PHP_BINARY;
if ($this->isWindows()) {
Copy link

@Bilge Bilge Sep 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should this just be for Windows? Either spaces need quoting when launching a process or they don't. This is not a platform-dependent problem.

$phpBin = '"'.$phpBin.'"';
}

$closure = function () {
return 0;
};
Expand All @@ -359,7 +364,7 @@ public function closureCommandHaveFullBinaryPaths(): void

$command = $event->buildCommand();

$this->assertSame(PHP_BINARY . " {$crunzBin} closure:run {$queryClosure}", $command);
$this->assertSame("{$phpBin} {$crunzBin} closure:run {$queryClosure}", $command);
}

/** @test */
Expand Down