Two points in this mail:
* The -G is going away in ack 2.0. It was a mistake to have two regexes passed to ack.
* What mechanic do we replace it with?
I'm removing -G in ack 2.0 because having more than one regex in an ack invocation is a bad thing.
When ack first started, there was no -f, no -g, no -G. ack would just take "ack regex", and ack would search for "regex".
Then I added -f to show what files were being searched. This let us say "ack -f" without a regex. It was handy.
Then I found myself doing "ack -f | ack regex" to find files that matched a given regex. So we added "ack -g regex" as a shortcut to do that. The flags that modify the regex like -w and -i worked with the regex when we were in -g mode.
And everything was good.
And then I added the -G flag. "ack -G fileregex contentregex" was equivalent to "ack contentregex $(ack -f fileregex)". Now we have confusion from two regexes in the same ack invocation. Which does -i modify? Which one does -w modify? What about inverting with -v?
So I'm making a design decision. ack 2.0 will only take a single regex anywhere in its invocation. That means -G has to go away.
That leaves a vacuum because ack -G is very handy. It's good to be able to say "ack -G core sales" to find "sales" in every file matching "core".
One way to do this is "ack sales $(ack -f core)". That works so long as "ack -f core" doesn't return more files than your shell can handle.
Another way is "ack -f core | xargs ack sales". That's a bit more typing. It also only works if you have xargs, which Windows people don't.
So here's my idea. We have a -x switch that says "take my files to read from stdin like xargs does". That way the invocation would be "ack -f core | ack -x sales". That's a little bit longer than "ack -G core sales", but not much.
ack -G core sales
ack -f core | ack -x sales
This gives us the unambiguous flexibility to have
ack -f -i core | ack -x sales -w
where that would not be possible with
ack -G core -i sales -w
So, I welcome your feedback on the -x flag. Does that seem like a viable solution? Should -x have to take a filename, and then we use -x- to mean "read from stdin"? Should the long version be --xargs to make it explicitly clear what it means?
Thanks,
xoxo,
Andy