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

No way to ignore a file in a folder #479

Closed AndrewRayCode closed 7 years ago

AndrewRayCode commented 10 years ago

From http://stackoverflow.com/questions/24815522/how-do-i-make-ack-ignore-a-file-in-a-directory/24824663#24824663

I have a file in a directory a/b/c.js

I can't ignore c.js with --ignore-file=match:c.js because I want to match other file named c.js

I can't ignore dir a/b with --ignore-dir=a/b because there are other files I care about in a/b

I've tried:

--ignore-file=a/b/c.js       "Invalid filter specification"

I've tried:

--ignore-file=match:/a\/b\/c.js/

Doesn't work, and I'm guessing that it's because ack doesn't read the file path as part of the match, just the name.

I've tried:

--ignore-dir=match:/a\/b\/c.js/     " Non-is filters are not yet supported for --ignore-dir (what?)"

I can't find anything useful in the Ack manual soup. How do I ignore a file in a directory?

hoelzro commented 10 years ago

@DelvarWorld You're completely right; I don't know if there is a way to do this. --ignore-file and --ignore-dir both only act on the last component in a file path (in this case, c.js), and you said you don't want to ignore other files with the same name, so that's out. Interestingly enough, though, is the fact that -g regexes apply to the whole path, but --ignore-* only apply to the last part of a path...

pmorch commented 10 years ago

I also find I'm needing this. We have a huge somedir/Makefile that is autogenerated. I want to search most Makefiles, just not that one.

What I'd like was to be able to put this in .ackrc:

--ignore-file-path=match:somedir/Makefile$

Expected Behavior

Ideally it always matches against the full name of the file all the way from /, similar to Perl's $File::Find::fullname. So that if I did this, it also ignored ./Makefile:

$ cd /path/to/somedir
$ ack foobar

But I could easily live with ./Makefile not being ignored, if ack only matches against the relative path. I'll run most acks somewere above somedir anyway.

petdance commented 7 years ago

This issue was moved to petdance/ack3#43

petdance commented 7 years ago

This will be addressed in ack3.