3

With ACK 2.x, I can specify command line options to exclude certain dirs from showing up in results. For example, to exclude the directory 'test' I can use:

ack -v -g 'test' | ack -x pattern ('test' can be a regex for dirs to exclude)

I can also ignore a directory using .ackrc, by adding --ignore-dir=save.d to .ackrc or using it as a command line option. But it seems that I cannot exclude paths (a dir and its subdirs) using RegEx. I tried adding the following:

--ignore-dir=match:^\/specific\/path\/to\/test\/.*$

and also the following variations

--ignore-dir=match:/^\/specific\/path\/to\/test\/.*$/

--ignore-dir=match:\/specific\/path\/to\/test\/.*

--ignore-dir=match:/specific/path/to/test/.*

--ignore-dir=match:/specific/path/to/test/

(according to this user, --ignore-dir and --ignore-file and indeed all file-match in ack is done with regular expressions, not with shell glob patterns, but I also tried using shell glob patterns.)

but this gives me:

Non-is filters are not yet supported for --ignore-dir at /usr/bin/ack line 157

Taking out the 'match:' part from the alternatives above does not produce an error, but doesn't exclude the dirs either.

The manual states that "nested directories like foo/bar are NOT supported". To settle this, on ACK at least up to ACK 2.12 it is impossible to exclude specific dirs and subdirectories. It's only possible to exclude all paths of which a dir matches a simple string or a regex. Or is there an undocumented clever way around this limitation?

Community
  • 1
  • 1
Gaia
  • 2,872
  • 1
  • 41
  • 59

1 Answers1

1

This isn't supported, I'm affraid. See

--ignore-dir doesn't support absolute pathnames · Issue #291 · petdance/ack2

I came to this post for something similar and found the above issue... :-(

Peter V. Mørch
  • 13,830
  • 8
  • 69
  • 103