From 5b8a87d0f61506d3a9d93dd4466f7b965b539599 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 26 Jan 2023 15:48:15 -0500 Subject: [PATCH] Slightly better `xonsh` check hack, fix typing --- tractor/_debug.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tractor/_debug.py b/tractor/_debug.py index be0e8de..47a9a88 100644 --- a/tractor/_debug.py +++ b/tractor/_debug.py @@ -197,7 +197,7 @@ class MultiActorPdb(pdbpp.Pdb): self.cmdloop() @cached_property - def shname(self) -> str: + def shname(self) -> str | None: ''' Attempt to return the login shell name with a special check for the infamous `xonsh` since it seems to have some issues much @@ -206,11 +206,18 @@ class MultiActorPdb(pdbpp.Pdb): ''' # SUPER HACKY and only really works if `xonsh` is not used # before spawning further sub-shells.. - xonsh_is_login_sh: bool = os.getenv('XONSH_LOGIN', default=False) - if xonsh_is_login_sh: - return 'xonsh' + shpath = os.getenv('SHELL', None) - return os.path.basename(os.getenv('SHELL')) + if shpath: + if ( + os.getenv('XONSH_LOGIN', default=False) + or 'xonsh' in shpath + ): + return 'xonsh' + + return os.path.basename(shpath) + + return None @acm