From 2817a473670c1027123b282651eef5f2dcfe9eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Simon?= Date: Mon, 29 Oct 2012 08:03:45 +0100 Subject: [PATCH] [Finder] Fixed filename containing space bug in gnu adapter. --- src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php b/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php index 6bd8ed9a2d61..3e1c82c65a07 100644 --- a/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php @@ -84,7 +84,7 @@ public function searchInDirectory($dir) $this->buildDatesFiltering($find, $this->dates); $useGrep = $this->shell->testCommand('grep') && $this->shell->testCommand('xargs'); - $useSort = is_int($this->sort) && $this->shell->testCommand('sort') && $this->shell->testCommand('awk'); + $useSort = is_int($this->sort) && $this->shell->testCommand('sort') && $this->shell->testCommand('cut'); if ($useGrep && ($this->contains || $this->notContains)) { $grep = $command->ins('grep'); @@ -286,8 +286,8 @@ private function buildSorting(Command $command, $sort) { switch ($sort) { case SortableIterator::SORT_BY_NAME: - $format = null; - break; + $command->ins('sort')->add('| sort'); + return; case SortableIterator::SORT_BY_TYPE: $format = '%y'; break; @@ -306,6 +306,6 @@ private function buildSorting(Command $command, $sort) $command->get('find')->add('-printf')->arg($format.' %h/%f\\n'); $command->ins('sort')->add('| sort'); - $command->ins('awk')->add('| awk')->arg('{ print $'.(null === $format ? '1' : '2').' }'); + $command->ins('awk')->add('| cut')->arg('-d ')->arg('-f2-'); } }