andy-5 / wslgit

Use Git installed in Bash on Windows/Windows Subsystem for Linux (WSL) from Windows and Visual Studio Code (VSCode)
MIT License
1.19k stars 59 forks source link

Changing default WSL shell with `chsh` breaks wslgit #107

Closed andy-5 closed 4 years ago

andy-5 commented 4 years ago

It seems possible now to change the default shell in WSL using chsh, so the previous workarounds using .bashrc etc. are not required anymore. However, changing the default shell in that way currently breaks wslgit, as all commands seem to be sent through the default shell.

For example, after changing the default shell to fish

chsh -s $(which fish)

all commands use the default fish shell, even when bash is executed with wsl.exe. For example, the output of

wsl.exe bash -c "echo $SHELL"

after changing the default shell is something like

/usr/bin/fish

and thus the bash syntax used by wslgit for path translations does not work.

I've pushed a fix to the develop branch which uses the -e flag to wsl.exe. This prevents the use of the default shell. However, this changes the required escaping. I simplified the escaping so that all tests still pass, but I think this might need some more testing. @carlolars, could you maybe test the latest changes if everything still works for your use cases?

carlolars commented 4 years ago

Will do! I see that you changed to 20.04, I'm still on 18.04 so had to modify tests. You could use wsl echo $WSL_DISTRO_NAME to get the distro name.

carlolars commented 4 years ago

No problems to report. 👍

andy-5 commented 4 years ago

Great, thanks for testing.