mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
Fix case where bash on path was failing.
This commit is contained in:
parent
27a37758c7
commit
435073af7e
1 changed files with 14 additions and 8 deletions
|
@ -299,22 +299,28 @@ def windows_bash_command():
|
|||
# Check that bash is on path otherwise try the default directory
|
||||
# used by Git for windows
|
||||
wbc = 'bash'
|
||||
bash_on_path = builtins.__xonsh_commands_cache__.lazy_locate_binary('bash',
|
||||
ignore_alias=True)
|
||||
cmd_cache = builtins.__xonsh_commands_cache__
|
||||
bash_on_path = cmd_cache.lazy_locate_binary('bash', ignore_alias=True)
|
||||
if bash_on_path:
|
||||
# Check if Bash is from the "Windows Subsystem for Linux" (WSL)
|
||||
# which can't be used by xonsh foreign-shell/completer
|
||||
out = subprocess.check_output([bash_on_path, '--version'],
|
||||
try:
|
||||
out = subprocess.check_output([bash_on_path, '--version'],
|
||||
stderr=subprocess.PIPE,
|
||||
universal_newlines=True)
|
||||
if 'pc-linux-gnu' in out.splitlines()[0]:
|
||||
except subprocess.CalledProcessError:
|
||||
bash_works = False
|
||||
else:
|
||||
# Check if Bash is from the "Windows Subsystem for Linux" (WSL)
|
||||
# which can't be used by xonsh foreign-shell/completer
|
||||
bash_works = 'pc-linux-gnu' not in out.splitlines()[0]
|
||||
|
||||
if bash_works:
|
||||
wbc = bash_on_path
|
||||
else:
|
||||
gfwp = git_for_windows_path()
|
||||
if gfwp:
|
||||
bashcmd = os.path.join(gfwp, 'bin\\bash.exe')
|
||||
if os.path.isfile(bashcmd):
|
||||
wbc = bashcmd
|
||||
else:
|
||||
wbc = bash_on_path
|
||||
return wbc
|
||||
|
||||
#
|
||||
|
|
Loading…
Add table
Reference in a new issue