beyondgrep / ack2

**ack 2 is no longer being maintained. ack 3 is the latest version.**
https://github.com/beyondgrep/ack3/
Other
1.48k stars 140 forks source link

Exclude generated C header and source files #573

Closed anand-hariharan closed 7 years ago

anand-hariharan commented 9 years ago

IDL files when compiled by Microsoft's MS-IDL compiler generate C and H files. They are typically thousands (sometimes tens of thousands) of lines long.

The only way of detecting that they are generated and not worth searching is that they have this as the THIRD line of the file:

/* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* this ALWAYS GENERATED file contains the IIDs and CLSIDs */

Request that ack provides a way to exclude such generated files.

petdance commented 7 years ago

I don't see how we could add a feature without getting extremely specific to this one case.

What I suggest is doing this:

ack -L 'this ALWAYS GENERATED file' | ack -x what_you_want_to_find

The first ack invocation gives a list of files that does NOT match this ALWAYS GENERATED file, and then pipes them to the second invocation which, because of the -x flag, takes that list as the list of files to use.