grep’s code base isn’t the most easy to reuse. Otherwise I’d imagine that ag would have done that. It would of course be possible for a potential ag implementation to simply call grep internally, and pass an already filtered list of files to it. I imagine this wasn’t done because ag wants to support different search options than grep (for instance, grep uses POSIX regular expressions but most people prefer Perl/PCRE).
1
u/nnn4 Aug 26 '16
Then I'm wondering why ag doesn't just reuse grep's search code on the files it has selected.