From 99bb88aeadfd89d00d998b2e8809db85e0fd01a6 Mon Sep 17 00:00:00 2001
From: Todd Gamblin <tgamblin@llnl.gov>
Date: Sun, 22 Mar 2020 20:47:04 -0700
Subject: bugfix: TERM may not be in the environment on Cray (#15630)

---
 lib/spack/spack/platforms/cray.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/spack/spack/platforms/cray.py b/lib/spack/spack/platforms/cray.py
index 8eae51e66a..6e8c79ef0c 100644
--- a/lib/spack/spack/platforms/cray.py
+++ b/lib/spack/spack/platforms/cray.py
@@ -117,9 +117,13 @@ class Cray(Platform):
         '''
         # env -i /bin/bash -lc echo $CRAY_CPU_TARGET 2> /dev/null
         if getattr(self, 'default', None) is None:
-            output = Executable('/bin/bash')('-lc', 'echo $CRAY_CPU_TARGET',
-                                             env={'TERM': os.environ['TERM']},
-                                             output=str, error=os.devnull)
+            bash = Executable('/bin/bash')
+            output = bash(
+                '-lc', 'echo $CRAY_CPU_TARGET',
+                env={'TERM': os.environ.get('TERM', '')},
+                output=str,
+                error=os.devnull
+            )
             output = ''.join(output.split())  # remove all whitespace
             if output:
                 self.default = output
-- 
cgit v1.2.3-70-g09d2