Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b7a85e0

Browse files
committed
merged branch havvg/hotfix/finder-spaces-in-dir (PR #7302)
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #7302). Commits ------- 3f3cf0c fix xargs pipe to work with spaces in dir names Discussion ---------- [Finder] fix xargs pipe to work with spaces in dir names | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT .. otherwise grep fails: ```` grep: : No such file or directory grep: /Users/havvg/Web: No such file or directory grep: Development/symfony2/src/Symfony/Component/Finder/Tests/Fixtures/dolor.txt: No such file or directory ```
2 parents 62f3d2a + f5dc03d commit b7a85e0

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

src/Symfony/Component/Finder/Adapter/BsdFindAdapter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ protected function buildContentFiltering(Command $command, array $contains, $not
9292
// todo: avoid forking process for each $pattern by using multiple -e options
9393
$command
9494
->add('| grep -v \'^$\'')
95-
->add('| xargs grep -I')
95+
->add('| xargs -I{} grep -I')
9696
->add($expr->isCaseSensitive() ? null : '-i')
9797
->add($not ? '-L' : '-l')
98-
->add('-Ee')->arg($expr->renderPattern());
98+
->add('-Ee')->arg($expr->renderPattern())
99+
->add('{}')
100+
;
99101
}
100102
}
101103
}

src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ protected function buildContentFiltering(Command $command, array $contains, $not
9393

9494
// todo: avoid forking process for each $pattern by using multiple -e options
9595
$command
96-
->add('| xargs -r grep -I')
96+
->add('| xargs -I{} -r grep -I')
9797
->add($expr->isCaseSensitive() ? null : '-i')
9898
->add($not ? '-L' : '-l')
99-
->add('-Ee')->arg($expr->renderPattern());
99+
->add('-Ee')->arg($expr->renderPattern())
100+
->add('{}')
101+
;
100102
}
101103
}
102104
}

src/Symfony/Component/Finder/Tests/FinderTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,11 @@ public function getTestPathData()
707707
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy',
708708
)
709709
),
710+
array('/^with space\//', 'foobar',
711+
array(
712+
'with space'.DIRECTORY_SEPARATOR.'foo.txt',
713+
)
714+
),
710715
);
711716

712717
return $this->buildTestData($tests);

src/Symfony/Component/Finder/Tests/Fixtures/with space/foo.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)