fix xargs pipe to work with spaces in dir names
This commit is contained in:
parent
95444058fe
commit
a735cbd02a
@ -92,10 +92,12 @@ class BsdFindAdapter extends AbstractFindAdapter
|
|||||||
// todo: avoid forking process for each $pattern by using multiple -e options
|
// todo: avoid forking process for each $pattern by using multiple -e options
|
||||||
$command
|
$command
|
||||||
->add('| grep -v \'^$\'')
|
->add('| grep -v \'^$\'')
|
||||||
->add('| xargs grep -I')
|
->add('| xargs -I{} grep -I')
|
||||||
->add($expr->isCaseSensitive() ? null : '-i')
|
->add($expr->isCaseSensitive() ? null : '-i')
|
||||||
->add($not ? '-L' : '-l')
|
->add($not ? '-L' : '-l')
|
||||||
->add('-Ee')->arg($expr->renderPattern());
|
->add('-Ee')->arg($expr->renderPattern())
|
||||||
|
->add('{}')
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,10 +93,12 @@ class GnuFindAdapter extends AbstractFindAdapter
|
|||||||
|
|
||||||
// todo: avoid forking process for each $pattern by using multiple -e options
|
// todo: avoid forking process for each $pattern by using multiple -e options
|
||||||
$command
|
$command
|
||||||
->add('| xargs -r grep -I')
|
->add('| xargs -I{} -r grep -I')
|
||||||
->add($expr->isCaseSensitive() ? null : '-i')
|
->add($expr->isCaseSensitive() ? null : '-i')
|
||||||
->add($not ? '-L' : '-l')
|
->add($not ? '-L' : '-l')
|
||||||
->add('-Ee')->arg($expr->renderPattern());
|
->add('-Ee')->arg($expr->renderPattern())
|
||||||
|
->add('{}')
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -707,6 +707,11 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
|||||||
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy',
|
'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);
|
return $this->buildTestData($tests);
|
||||||
|
Reference in New Issue
Block a user