Improvements to non-interactive shell detection suggested by greg_1_anderson.