Make cwd check more robust

Apparently getcwd() raises an exception on macOS when the cwd does not
exist.
This commit is contained in:
Kovid Goyal
2018-03-27 10:54:49 +05:30
parent faac8649e4
commit 57f1bbb71a

View File

@@ -141,7 +141,11 @@ def _main():
if is_macos and os.environ.pop('KITTY_LAUNCHED_BY_LAUNCH_SERVICES', None) == '1':
os.chdir(os.path.expanduser('~'))
args = macos_cmdline()
if not os.path.isdir(os.getcwd()):
try:
cwd_ok = os.path.isdir(os.getcwd())
except Exception:
cwd_ok = False
if not cwd_ok:
os.chdir(os.path.expanduser('~'))
args, rest = parse_args(args=args)
args.args = rest