Skip to content

Commit

Permalink
[Process] fix interpolation of placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Feb 28, 2018
1 parent a1b2414 commit a5f58f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Process/Process.php
Expand Up @@ -1554,7 +1554,7 @@ private function escapeArgument(string $argument): string

private function replacePlaceholders(string $commandline, array $env)
{
$pattern = '\\' === DIRECTORY_SEPARATOR ? '!%s!' : '${%s}';
$pattern = '\\' === DIRECTORY_SEPARATOR ? '!%s!' : '"$%s"';

return preg_replace_callback('/\{\{ ?([_a-zA-Z0-9]++) ?\}\}/', function ($m) use ($pattern, $commandline, $env) {
if (!isset($env[$m[1]]) || false === $env[$m[1]]) {
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Process/Tests/ProcessTest.php
Expand Up @@ -1476,10 +1476,10 @@ public function provideEscapeArgument()

public function testPreparedCommand()
{
$p = new Process('echo {{ abc }}DEF');
$p->run(null, array('abc' => 'ABC'));
$p = new Process(self::$phpBin.' -r \'print_r($argv);\' {{ abc }}DEF');
$p->run(null, array('abc' => 'A" B "C'));

$this->assertSame('ABCDEF', rtrim($p->getOutput()));
$this->assertContains('A" B "CDEF', $p->getOutput());
}

/**
Expand Down

0 comments on commit a5f58f2

Please sign in to comment.