summaryrefslogtreecommitdiff
path: root/alot/helper.py
diff options
context:
space:
mode:
authorJulian Mehne <julian.mehne@posteo.de>2018-01-21 19:08:19 +0100
committerJulian Mehne <julian.mehne@posteo.de>2018-01-21 20:10:09 +0100
commit0935ccfd5c8cd00dd7b55a06133c6b5cf6368668 (patch)
treef6278deddadc2813a226f818eeb3c61f154a0daf /alot/helper.py
parent6f1a8b687dde23458b141c36f3044cf10fa008af (diff)
Fix empty XDG_* environment variables.
Use fallback, if an enviroment variable is unset *or* empty. Bug: - XDG_CONFIG_HOME='' alot Problem: Does not find the configuration file (among others), because os.environ.get('XDG_CONFIG_HOME', '~/.config') returns '', instead of '~/.config'.
Diffstat (limited to 'alot/helper.py')
-rw-r--r--alot/helper.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/alot/helper.py b/alot/helper.py
index be5191d8..06362e06 100644
--- a/alot/helper.py
+++ b/alot/helper.py
@@ -625,3 +625,9 @@ def email_as_string(mail):
as_string, flags=re.MULTILINE)
return as_string
+
+
+def get_env(env_name, fallback):
+ """ Gets environment variable and returns fallback if unset or empty """
+ env = os.environ.get(env_name)
+ return env if env else fallback