Skip to content

Commit a5f58f2

Browse files
[Process] fix interpolation of placeholders
1 parent a1b2414 commit a5f58f2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,7 @@ private function escapeArgument(string $argument): string
15541554

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

15591559
return preg_replace_callback('/\{\{ ?([_a-zA-Z0-9]++) ?\}\}/', function ($m) use ($pattern, $commandline, $env) {
15601560
if (!isset($env[$m[1]]) || false === $env[$m[1]]) {

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,10 +1476,10 @@ public function provideEscapeArgument()
14761476

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

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

14851485
/**

0 commit comments

Comments
 (0)