Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

Closed
stephenmckinney opened this Issue Mar 26, 2012 · 22 comments

Comments

Projects
None yet
4 participants

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.

Collaborator

petdance commented Mar 26, 2012

What command line are you using exactly?

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

Collaborator

petdance commented Mar 26, 2012

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.

Collaborator

petdance commented Mar 26, 2012

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.

Collaborator

petdance commented Mar 26, 2012

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.

Collaborator

petdance commented Mar 26, 2012

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

Collaborator

petdance commented Mar 26, 2012

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?

Collaborator

petdance commented Mar 26, 2012

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!

@petdance petdance reopened this Mar 26, 2012

Collaborator

petdance commented Mar 26, 2012

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.

Collaborator

petdance commented Mar 26, 2012

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?

Collaborator

petdance commented Apr 21, 2013

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?

Collaborator

petdance commented Apr 21, 2013

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?

@hoelzro hoelzro referenced this issue in beyondgrep/ack2 Aug 28, 2013

Closed

Allow --ignore-dir to work on relative paths #330

Collaborator

hoelzro commented Aug 28, 2013

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

@hoelzro hoelzro closed this Aug 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment