Cleaner environment

Leak fewer transients into the environment, make the script set -u clean, handle shell metachars in paths, and make fatal errors fatal.

Several things still leak into the user environment, but those would be hard to stop or would trade documentation and didn't seem worth it.

Bear in mind I don't have a setup with which to test this, so there may be bugs.