microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
161.23k stars 28.31k forks source link

Adapt the bash of busybox. #170868

Open fxzxmic opened 1 year ago

fxzxmic commented 1 year ago

Steps to Reproduce:

  1. Start a terminal.
  2. image

I use busybox bash as /bin/bash (still busybox ash in essence), which is why there is no .bashrc. I hope vs code server can judge whether it is a real bash before using it, if not, treat the bash as ash.

Does this issue occur when you try this locally?: No Does this issue occur when you try this locally and all extensions are disabled?: No

fxzxmic commented 1 year ago

In fact, busybox bash/ash does not support the builtin command. I've found the way to set /bin/ash as the default shell of vscode instead of the automatically detected /bin/bash, so I don't know if this problem still needs to be fixed.

Tyriar commented 1 year ago

Thanks, it's still an issue then. We should detect if it's busybox either before injecting the shell integration or at the start of the script.

meganrogge commented 1 year ago

I'll create another issue for the case when there's no .bashrc file so that gets verified

fxzxmic commented 1 year ago

Check whether $BASH_VERSION exists? This is probably the easiest way.

When I delete the code for reading .bashrc and the builtin command, it still reports an error. image image It seems that busybox bash/ash is not compatible with this script.

Perhaps there could be an injection script for busybox bash/ash?

Tyriar commented 8 months ago

This is available for contributions. I believe all this needs is an if here to exit early if it is busybox:

https://github.com/microsoft/vscode/blob/d70a46b6bd65aade0248f900a6e67a85f1c2cde2/src/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh#L6-L9

It needs to be tested of course and be a low risk change for regular bash.

fxzxmic commented 5 months ago

Perhaps we should exit the script when we detect that this is not a true bash, or only perform some necessary injections. Otherwise, it would be too complicated to fully adapt to Busybox's bash.