env-setup tweaks (POSIX-compliance) 2.1

This series of commits turns env-setup into a POSIX-compliant shell script, so that it can be used from shells like dash and ksh just the same.

The sourcing error in bash should be history.

Rebased onto current devel.