Closed epa closed 10 years ago
Hi @epa,
Have you looked at the -g
option? I think it does exactly what you want!
Please note that -g
is not a general purpose filename searcher. It's a filtered-by-regex version of the -f
flag, which itself finds source code files.
-g is useful but it requires running two ack commands for each search; 'ack foo' followed by 'ack -g foo'. It would be more convenient to have a configuration setting to specify that every 'ack foo' should search filenames as well as content. Possibly, this config setting could even be made the default.
You're saying that you want ack foo
to show you lines that match "foo", and also filenames that match "foo"? That's not a feature I can support. I appreciate the need you have, and the request, and I can see how that would be useful, but that would make ack do too much at once.
Yes that would be ideal, but I recognize that my preference may not be shared by everyone, so I'd be happy for it to be some non-default config option.
I do think, though, that the common task of 'search this codebase for some word' encompasses checking filenames as well as content, and it would be more convenient to have one command to do that rather than two. That convenience, after all, is the main reason to use ack instead of grep/find/whatever.
...alternatively, if -g would work together with normal usage that would take care of it. At the moment ack foo -g foo
doesn't do it, but I guess it could.
When you do 'ack foo', then ack should also report the names of files under the current directory containing 'foo'. It doesn't need to report anything about the contents of these files (unless they match the search expression anyway, of course), just the fact that the name matches.
I suggest this would make ack a better fit for the common programmer task of finding out where a particular string is mentioned in a codebase. Often a program will work by looking at the filenames it finds, and so to find where on earth "Poodle" is coming from it is useful for ack to flag up the existence of a file Poodle.config even if the string doesn't occur in the content.
I suggest that the full pathname of the file relative to the current directory be matched against the regular expression.