Check if the environment variable TERM is defined before using it.
This fixes: <rdar://problem/6164279> scan-build gives error when invoked without TERM variable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56110 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/scan-build b/utils/scan-build
index 908795e..e0d53ad 100755
--- a/utils/scan-build
+++ b/utils/scan-build
@@ -26,8 +26,9 @@
my $BuildDate;
my $CXX; # Leave undefined initially.
-my $UseColor = ((($ENV{'TERM'} eq 'xterm-color') and -t STDOUT)
- and defined($ENV{'SCAN_BUILD_COLOR'}));
+my $TERM = $ENV{'TERM'};
+my $UseColor = (defined $TERM and $TERM eq 'xterm-color' and -t STDOUT
+ and defined $ENV{'SCAN_BUILD_COLOR'});
##----------------------------------------------------------------------------##
# Diagnostics