cleanup and comments
a test for direct piping
preferred encodings are all caps
breaking up inline conditionals, making the code more readable
always exit from our child process, even on exception.  and make sure our cwd exists