I am currently writing some convenience methods for my terminal in my bash_profile and am sure if what I am writing is "the best way". I figure a good way to verify whether what I'm doing is right or not would be to find some source code of more established programs and see how they do it.
My question then is, where can I find this code on my Mac? An example is, with Macports installed, where is the source code that opens the port interactive console when I type nothing but "port" in my shell?
(I added Linux in the title even though I am on a Mac because I assume the answer would be the same for both)
Edit: The answer I am looking for is in terms of which directory relative to the programs will I find their unix scripts.