File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Filter options
src/Symfony/Component/Process Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Original file line number Diff line number Diff line change @@ -304,10 +304,10 @@ public function start(callable $callback = null, array $env = [])
304
304
$ descriptors = $ this ->getDescriptors ();
305
305
306
306
if ($ this ->env ) {
307
- $ env += $ this ->env ;
307
+ $ env += '\\' === \ DIRECTORY_SEPARATOR ? array_diff_ukey ( $ this -> env , $ env , ' strcasecmp ' ) : $ this ->env ;
308
308
}
309
309
310
- $ env += $ this ->getDefaultEnv ();
310
+ $ env += '\\' === \ DIRECTORY_SEPARATOR ? array_diff_ukey ( $ this -> getDefaultEnv (), $ env , ' strcasecmp ' ) : $ this ->getDefaultEnv ();
311
311
312
312
if (\is_array ($ commandline = $ this ->commandline )) {
313
313
$ commandline = implode (' ' , array_map ([$ this , 'escapeArgument ' ], $ commandline ));
@@ -1659,8 +1659,8 @@ private function replacePlaceholders(string $commandline, array $env)
1659
1659
private function getDefaultEnv (): array
1660
1660
{
1661
1661
$ env = getenv ();
1662
- $ env = array_intersect_key ($ env , $ _SERVER ) ?: $ env ;
1662
+ $ env = ( '\\' === \ DIRECTORY_SEPARATOR ? array_intersect_ukey ( $ env , $ _SERVER , ' strcasecmp ' ) : array_intersect_key ($ env , $ _SERVER ) ) ?: $ env ;
1663
1663
1664
- return $ _ENV + $ env ;
1664
+ return $ _ENV + ( '\\' === \ DIRECTORY_SEPARATOR ? array_diff_ukey ( $ env, $ _ENV , ' strcasecmp ' ) : $ env ) ;
1665
1665
}
1666
1666
}
Original file line number Diff line number Diff line change @@ -1522,6 +1522,18 @@ public function testWaitStoppedDeadProcess()
1522
1522
$ this ->assertFalse ($ process ->isRunning ());
1523
1523
}
1524
1524
1525
+ public function testEnvCaseInsensitiveOnWindows ()
1526
+ {
1527
+ $ p = $ this ->getProcessForCode ('print_r([$_SERVER[ \'PATH \'] ?? 1, $_SERVER[ \'Path \'] ?? 2]); ' , null , ['PATH ' => 'bar/baz ' ]);
1528
+ $ p ->run (null , ['Path ' => 'foo/bar ' ]);
1529
+
1530
+ if ('\\' === \DIRECTORY_SEPARATOR ) {
1531
+ $ this ->assertSame ('Array ( [0] => 1 [1] => foo/bar ) ' , preg_replace ('/\s++/ ' , ' ' , trim ($ p ->getOutput ())));
1532
+ } else {
1533
+ $ this ->assertSame ('Array ( [0] => bar/baz [1] => foo/bar ) ' , preg_replace ('/\s++/ ' , ' ' , trim ($ p ->getOutput ())));
1534
+ }
1535
+ }
1536
+
1525
1537
/**
1526
1538
* @param string|array $commandline
1527
1539
* @param mixed $input
You can’t perform that action at this time.
0 commit comments