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

-s option has no effect when -x option is used #676

Closed kawing-chiu closed 5 years ago

kawing-chiu commented 5 years ago

I'm using ack 2.24. According to the doc, -s should suppress error messages about nonexistent files etc. However, when file list is read from stdin, it does not work:

$ ack -s some_pattern not_exist
$ echo not_exist | ack -s -x some_pattern
ack: not_exist: No such file
petdance commented 5 years ago

That's frustrating. :-/ Thanks for reporting it.

But I'm glad to see folks using the -x switch!

kawing-chiu commented 5 years ago

Thanks for the prompt reply! For the time being, here's a workaround I use:

$ echo not_exist | xargs ls -d 2>/dev/null | ack -x some_pattern
petdance commented 5 years ago

I'll fix it in ack itself. I don't think it will be that big of a deal.

While I have your attention, can you tell me more about how you're using -x? I rarely see people mention it, and it's one of my favorite features. Did you just stumble across it in the docs and think "Hey, that's handy"?

kawing-chiu commented 5 years ago

Ack is my choice of vim's grepprg. I use the -x option so that I can use other program to narrow down what to search first. In a large project, searching directly on a raw directory is infeasible. For example, my python project has a lot of cython-generated .c files in the src directory that I never want to touch. So my grepprg looks like:

let &grepprg = 'git ls-files -co --exclude-standard -z \| xargs -0 ls -d 2>/dev/null \| ack -x'

I do similar thing to other search-related plugins like ctrl-p, too. Don't know whether this is the correct way, though.

petdance commented 5 years ago

This has been fixed in ack3. There will be no more releases of ack 2.