Skip to content

Commit

Permalink
Updated _get_user_dir to handle situations with no $HOME directory
Browse files Browse the repository at this point in the history
  • Loading branch information
devttys0 committed May 16, 2018
1 parent 298cc28 commit d8f0edf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/binwalk/core/settings.py
Expand Up @@ -128,11 +128,16 @@ def _get_user_dir(self):
'''
try:
# This should work in both Windows and Unix environments
return os.getenv('USERPROFILE') or os.getenv('HOME')
for envname in ['USERPROFILE', 'HOME']:
user_dir = os.getenv(envname)
if user_dir is not None:
return user_dir
except KeyboardInterrupt as e:
raise e
except Exception:
return ''
pass

return ''

def _file_path(self, dirname, filename):
'''
Expand Down

0 comments on commit d8f0edf

Please sign in to comment.