beyondgrep/ack1

--ignore-dir=./media doesn't ignore files in ./media

Closed this issue · 22 comments

The directory structure:
app/grants
app/media
app/promo
media
settings
....

I want to ignore media but not app/media. but --ignore-dir=./media and --ignore-dir=/media don't work.

What command line are you using exactly?

ck 1.96
Running under Perl 5.12.3 at /usr/bin/perl

I mean what command are you executing that makes you say "it doesn't work"? Please give the full command line you're using.

When I execute:
ack --ignore-dir=./media test_string or ack --ignore-dir=/media test_string

The expected result would be:
Ack finds 'test_string' within ./app/media but not in ./media

The actual result:
Ack finds 'test_string' in both directories.

Are you specifying any filenames? Are you literally only executing ack --ignore-dir=/media test_string? Filenames specified on the command line override everything via --ignore-dir and similar file selection switches.

Certainly --ignore-dir=/media won't work because you're not searching the root of the filesystem.

literally ack --ignore-dir=./media test_string. no filenames or filetype switches. I threw /media out there as a last ditch effort after ./meda didn't work as expected.

What if you try --ignore-dir=media ?

--ignore-dir=media ignores ./media and ./app/media, as expected. My goal is to specifically ignore ./media but continue searching in ./app/media

I think you're stuck as far as ack 1.x goes, then. ack 2.0 will make specifications much more flexible. I'm sorry. :-(

understood. i'll work around it. no pressure, but are you targeting a release date for 2.0?

No release date, but you can follow our work (and pitch in!) at https://github.com/petdance/ack2 here on github.

Nice! I had no idea there was a separate repo. I don't know Perl (so I probably won't be able to commit much code), but I could always run beta builds and provide feedback.

Thanks for awesome tool!

Thanks for the kind words. I don't advertise ack 2.0 too much because I don't have a satisfactory answer for the "when will it be out" follow-up question.

I've re-opened this issue because it's still a problem, and will help inform our decisions on ack 2.

One other thing: Join the ack-users list. I ask a lot of design questions there. We always need more users who are willing to give input.

@petdance Now that ack2 is out, am I missing something on how to do this? So far --ignore-dir=./media doesn't actually seem to exclude ./media and --ignore-dir=media excludes ./media and also ./app/media.

Any ideas?

I don't have an answer for this right now. I'm not sure what the right behavior should be.

Well, ideally if a dirname starts with ./ then we can assume relative path and only exclude that one, vs if I pass in just the dirname then any directory named that would be removed.

The behavior seems logical to me as is right now for --ignore-dir=media because it is removing any directory named media including ./media and ./app/media.

What doesn't make sense is, especially if --ignore-dir now supports relative paths, why --ignore-dir=./media doesn't actually exclude ./media. Is this perhaps a bug?

I agree, that does make sense. But there are other things that might make sense as well.

Yes, I will call this a bug.

In the meantime, there is likely a way to achieve this with the new -x option.

In fact, ack -g '^(!?media)' | ack -x <query> works. But is there anyway I can do something in a per-project ackrc that will execute the equivalent of piping -g into -x?

Moved to the ack2 queue (beyondgrep/ack2#330)