Fix case where bash on path was failing.

This commit is contained in:
Morten Enemark Lund 2017-02-20 08:15:42 +01:00
parent 27a37758c7
commit 435073af7e

View file

@ -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
#