about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2021-08-28 11:44:00 +0200
committertoonn <toonn@toonn.io>2021-08-28 11:44:00 +0200
commit7954b2fa2341bd33c59a110959790134fc5f0a75 (patch)
tree53292f1bab9eabeaf082e808c2bfd4d9350eeba0 /ranger
parent6333f398c4e93501dd9772f24622963712d21e3c (diff)
downloadranger-7954b2fa2341bd33c59a110959790134fc5f0a75.tar.gz
ui: Fix crash when TMUX not in environment
Made a mistake when merging #2201. If the "TMUX" key isn't in the
environment dictionary we'll get a KeyError. Providing an empty string
default should fix the problem.

I applied the same logic to the check for screen because TERM isn't
guaranteed to be in the environment either, though this verges os
malicious.
Diffstat (limited to 'ranger')
-rw-r--r--ranger/gui/ui.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index 4fadd4ec..db12d6dc 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -51,12 +51,12 @@ def _setup_mouse(signal):
 
 
 def _in_tmux():
-    return (os.environ.get('TMUX')
+    return (os.environ.get("TMUX", "")
             and 'tmux' in get_executables())
 
 
 def _in_screen():
-    return ('screen' in os.environ['TERM']
+    return ('screen' in os.environ.get("TERM", "")
             and 'screen' in get_executables())