3

When I do

ack -G "^.*$" "foo"

I get results... but when I put

-G "^.*$"

or

-G="^.*$"

or

-G
"^.*$"

in my `~/.ackrc/ I get no results... Does anyone know if -G can be used in ackrc?

Aaron Gibralter
  • 4,773
  • 3
  • 35
  • 50
  • Just as a sanity check, you aren't using `--noenv` are you? Do other options work when placed in `~/.ackrc`? – Greg Hewgill Mar 24 '11 at 21:03
  • Yeah, I removed everything from `~/.ackrc` except `-G="^.*$"` and ran `ack "foo"` from the command line. Nothing showed up... but then when I remove the line from `~/.ackrc` I get results for foo. – Aaron Gibralter Mar 24 '11 at 21:19

2 Answers2

4

It's a quoting problem. When executed on the command line:

$ ack -G="^.*$"

ack actually sees the following command line option (after quote processing by the shell)

-G=^.*$

without the quotes. Since the ~/.ackrc file is read without shell quote processing, place the above line without quotes into ~/.ackrc.

Update: That was only half of it. It looks like you need to use the following line in ~/.ackrc:

-G^.*$

I'm not completely sure why the = is not permitted there, but including it makes it part of the pattern, which is obviously not what you want.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • Unfortunately, that doesn't seem to make a difference. When I have `-G=^.*$` as the only line in `~/.ackrc` I still get no results... – Aaron Gibralter Mar 24 '11 at 21:26
  • What are you actually trying to do with that? Would the `-a` option work for you? – Greg Hewgill Mar 24 '11 at 21:27
  • I'm trying to ignore directories with a little intelligence. I'm trying to do something like this: http://stackoverflow.com/questions/2799570/ack-excluding-only-one-directory-but-keeping-all-others-with-the-same-name. I want to `--ignore-dir` `vendor` but not `app/javascripts/vendor`... – Aaron Gibralter Mar 24 '11 at 21:39
  • 2
    BINGO! You're update fixed it. I basically wanted this: `-G^(?!vendor|log|tmp|doc|coverage|public/app).*$` to have more fine-grained control over the way directories are ignored. – Aaron Gibralter Mar 24 '11 at 21:42
0

You could alias ack to ack -G ?

Monolo
  • 18,205
  • 17
  • 69
  • 103
Paul Creasey
  • 28,321
  • 10
  • 54
  • 90