mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-31 10:11:14 +00:00
Update _get_shell to work with Windows
- _get_shell assumed the parent process would always be the shell process, in Powershell the parent process is Python, with the grandparent being the shell - Switched to walking the process tree so the same code path can be used in both places
This commit is contained in:
parent
39f7cc37eb
commit
2207dd2668
@ -18,11 +18,26 @@ shells = {'bash': Bash,
|
|||||||
|
|
||||||
|
|
||||||
def _get_shell():
|
def _get_shell():
|
||||||
try:
|
proc = Process(os.getpid())
|
||||||
shell_name = Process(os.getpid()).parent().name()
|
|
||||||
except TypeError:
|
while (proc is not None):
|
||||||
shell_name = Process(os.getpid()).parent.name
|
name = None
|
||||||
return shells.get(shell_name, Generic)()
|
try:
|
||||||
|
name = proc.name()
|
||||||
|
except TypeError:
|
||||||
|
name = proc.name
|
||||||
|
|
||||||
|
name = os.path.splitext(name)[0]
|
||||||
|
|
||||||
|
if name in shells:
|
||||||
|
return shells[name]()
|
||||||
|
|
||||||
|
try:
|
||||||
|
proc = proc.parent()
|
||||||
|
except TypeError:
|
||||||
|
proc = proc.parent
|
||||||
|
|
||||||
|
return Generic()
|
||||||
|
|
||||||
|
|
||||||
shell = _get_shell()
|
shell = _get_shell()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user