This is an alternative fix for https://github.com/emscripten-core/emscripten/issues/9090 which recently came up again after #539. Tested with bash, tcsh and fish.
Remove the optional argument to contruct_env. It simple if we always construct the env in the same place. Avoid using temp files, and avoid changing directory.