diff --git a/src/Symfony/Component/Finder/Adapter/BsdFindAdapter.php b/src/Symfony/Component/Finder/Adapter/BsdFindAdapter.php index d11ea3e25d80a..c49a07c8f6df7 100644 --- a/src/Symfony/Component/Finder/Adapter/BsdFindAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/BsdFindAdapter.php @@ -92,10 +92,12 @@ protected function buildContentFiltering(Command $command, array $contains, $not // todo: avoid forking process for each $pattern by using multiple -e options $command ->add('| grep -v \'^$\'') - ->add('| xargs grep -I') + ->add('| xargs -I{} grep -I') ->add($expr->isCaseSensitive() ? null : '-i') ->add($not ? '-L' : '-l') - ->add('-Ee')->arg($expr->renderPattern()); + ->add('-Ee')->arg($expr->renderPattern()) + ->add('{}') + ; } } } diff --git a/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php b/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php index a235742c01e6a..b332b97038689 100644 --- a/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php @@ -93,10 +93,12 @@ protected function buildContentFiltering(Command $command, array $contains, $not // todo: avoid forking process for each $pattern by using multiple -e options $command - ->add('| xargs -r grep -I') + ->add('| xargs -I{} -r grep -I') ->add($expr->isCaseSensitive() ? null : '-i') ->add($not ? '-L' : '-l') - ->add('-Ee')->arg($expr->renderPattern()); + ->add('-Ee')->arg($expr->renderPattern()) + ->add('{}') + ; } } } diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 33750fc27613d..b9198178f0558 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -735,6 +735,11 @@ public function getTestPathData() 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy', ) ), + array('/^with space\//', 'foobar', + array( + 'with space'.DIRECTORY_SEPARATOR.'foo.txt', + ) + ), ); return $this->buildTestData($tests); diff --git a/src/Symfony/Component/Finder/Tests/Fixtures/with space/foo.txt b/src/Symfony/Component/Finder/Tests/Fixtures/with space/foo.txt new file mode 100644 index 0000000000000..e69de29bb2d1d