Add another test to detect a non interactive shell. This may be the best method....