/** * {@inheritdoc} */ protected function buildContentFiltering(ehough_finder_shell_Command $command, array $contains, $not = false) { foreach ($contains as $contain) { $expr = ehough_finder_expression_Expression::create($contain); // todo: avoid forking process for each $pattern by using multiple -e options $command->add('| grep -v \'^$\'')->add('| xargs -I{} grep -I')->add($expr->isCaseSensitive() ? null : '-i')->add($not ? '-L' : '-l')->add('-Ee')->arg($expr->renderPattern())->add('{}'); } }
/** * @param ehough_finder_shell_Command $command * @param ehough_finder_comparator_DateComparator[] $dates */ private function buildDatesFiltering(ehough_finder_shell_Command $command, array $dates) { foreach ($dates as $i => $date) { $command->add($i > 0 ? '-and' : null); $mins = (int) round((time() - $date->getTarget()) / 60); if (0 > $mins) { // mtime is in the future $command->add(' -mmin -0'); // we will have no result so we don't need to continue return; } switch ($date->getOperator()) { case '<=': $command->add('-mmin +' . ($mins - 1)); break; case '>=': $command->add('-mmin -' . ($mins + 1)); break; case '>': $command->add('-mmin -' . $mins); break; case '!=': $command->add('-mmin +' . $mins . ' -or -mmin -' . $mins); break; case '<': default: $command->add('-mmin +' . $mins); } } }
public function testCastToString() { $cmd = ehough_finder_shell_Command::create(); $cmd->add('--force'); $cmd->add('--run'); $this->assertSame('--force --run', (string) $cmd); }
/** * @param ehough_finder_adapter_AdapterInterface $adapter * @param ehough_finder_shell_Command $command * @param Exception|null $previous */ public function __construct(ehough_finder_adapter_AdapterInterface $adapter, ehough_finder_shell_Command $command, Exception $previous = null) { $this->command = $command; parent::__construct($adapter, 'Shell command failed: "' . $command->join() . '".', $previous); }