Getting presented with a large and unfamiliar code base can sometimes prove daunting. One of the biggest challenges is how to efficiently search for things when you need to make changes.
Since I'm a big fan of platform independent tools, I had been using recursive grep searches but those frequently return too many results. It can be difficult to limit the files searched to just the source files of interest. Perhaps you have a unit test directory you don't wish to search. You might also want to skip directories containing library files or other binaries. I prefer a tool called ack to help limit the unwanted files being searched. That prevents lots of false positives which you need to wade through.
Creating a file called .ackrc in your home directory is an easy way of setting the default settings for ack. The following sample .ackrc file configures ack to ignore a few directories which normally don't contain code of interest. It also sets an alternate file extension for makefiles and configures the default source languages of interest.
--ignore-dir=.svn
--ignore-dir=dist
--ignore-dir=docs
--ignore-dir=examples
--ignore-dir=lib
--ignore-dir=tests
--type-add=make:ext:make
--asm
--cc
--make
Using ack and an appropriately configured .ackrc file can significantly reduce the number of lines of matches you must check when searching your source tree for a keyword.
This blog is intended to give me a place to comment on things which strike my fancy, hence the title. Topics may include computer software or hardware, science, space, books, movies, television programs of a geeky nature, or almost anything else.
Subscribe to:
Post Comments (Atom)
-
A long time ago I was given a bit of advice that has served me well over the years. An engineer with much more experience than I had at the...
-
We lost our very special dog to an osteosarcoma a few days ago. He started limping a little over 4 months ago and it took a while to dia...
-
Most of the longtime Unix users like me love grep. Regular expressions make the silly wildcards available in Windows seem completely underw...
No comments:
Post a Comment