tidied up environment conditionals
Merge pull request #1475 from inolen/env_tidy

tidied up environment conditionals in shell