Merge pull request #81 from mattrose/issue58

fix FileNotFound error when terminator is run from a directory that no longer exists
This commit is contained in:
Matt Rose 2020-05-15 11:46:49 -04:00 committed by GitHub
commit b800fbaea3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 6 deletions

View File

@ -25,11 +25,10 @@ except (ImportError):
def get_default_cwd(): def get_default_cwd():
"""Determine a reasonable default cwd""" """Determine a reasonable default cwd"""
cwd = os.getcwd()
if not os.path.exists(cwd) or not os.path.isdir(cwd):
try: try:
cwd = pwd.getpwuid(os.getuid())[5] cwd = os.getcwd()
except KeyError: except (FileNotFoundError,OSError):
err("unable to set current working directory, does not exist")
cwd = '/' cwd = '/'
return(cwd) return(cwd)