8000 [Finder] fix xargs pipe to work with spaces in dir names by havvg · Pull Request #7302 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Finder] fix xargs pipe to work with spaces in dir names #7302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Symfony/Component/Finder/Adapter/BsdFindAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('{}')
;
}
}
}
6 changes: 4 additions & 2 deletions src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('{}')
;
}
}
}
5 changes: 5 additions & 0 deletions src/Symfony/Component/Finder/Tests/FinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Empty file.
0