Make the tmpdir hack less hackish.

We now replicate the (GNU-only) --tmpdir option in shell code.  This
should work on both Mac and Linux, whether or not $TMPDIR is set.