Refactor: CTS: Add a function for applying substitutions to a string
The basic idea here is that we can provide a dict of things that it's
tedious to add to every command string (or environment variable
expansion, or whatever) and have python do it for us. The only tricky
part about this is remembering what is available.