fix xargs pipe to work with spaces in dir names

This commit is contained in:
Toni Uebernickel 2013-03-08 14:43:57 +01:00
parent 95444058fe
commit a735cbd02a
4 changed files with 13 additions and 4 deletions

View File

@ -92,10 +92,12 @@ class BsdFindAdapter extends AbstractFindAdapter
// 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('{}')
;
}
}
}

View File

@ -93,10 +93,12 @@ class GnuFindAdapter extends AbstractFindAdapter
// 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('{}')
;
}
}
}

View File

@ -707,6 +707,11 @@ class FinderTest extends Iterator\RealIteratorTestCase
'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);