Add environment code

This should have been part of commit
8b0ddd1bff47f4c914ec8c1df9242233fe10e78d
Change how pipeline debug output is generated

The old approach made it easy to generate pipeline debug output which
didn't match the pipeline we actually ran.  The new code generates the
output as the commands themselves are being prepared.  This guarantees
that they'll agree.
Use 'git grep' if possible

In most circumstances, when searching inside a Git repository, the
fastest thing you can possibly do is run 'git grep'.  It has some clever
tricks up its sleeve.

There are circumstances (like when 'mdfind' is available or when
restricting a search to files of a specific language) where we might be
able to outperform 'git grep', but we're not there yet.