Integrated Terminal with remote SSH and bash clobbers exit code to zero #221393
Labels
bug
Issue identified by VS Code Team member as probable bug
insiders-released
Patch has been released in VS Code Insiders
terminal-shell-bash
An issue in the terminal specific to bash, including shell integration
terminal-shell-integration
Shell integration infrastructure, command decorations, etc.
verified
Verification succeeded
Milestone
Type: Bug
The issue shows up if I have a custom PS1 prompt that looks at the exit code of the previous command (using
$?
). Here's a minimal configuration in the .bashrc file on my remote Linux host:Expected results: When I run in a terminal outside vscode or disable automatic script injection in the integrated terminal, I get this:
Actual results: when I enable integrated terminal shell injection, I instead see this output running the same commands:
That is, the exit code is now always 0.
I tried manually injecting the scripts using the command from https://code.visualstudio.com/docs/terminal/shell-integration#_installation
. "$(code --locate-shell-integration-path bash)"
; no change in behavior.Looking at the script that gets loaded (.../server/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh), I see these lines:
As an experiment, I tried moving the
__vsc_restore_exit_code
call later and opening a new terminal, which fixed the issue for me:So it looks like the step that clobbers the exit code is the
local cmd
step.Remote OS: RHEL 8.10, bash 4.4.20
VS Code version: Code 1.91.0 (ea1445c, 2024-07-01T18:52:22.949Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 4.18.0-553.5.1.el8_10.x86_64
Remote OS version: Linux x64 4.18.0-553.5.1.el8_10.x86_64
Remote OS version: Linux x64 4.18.0-553.5.1.el8_10.x86_64
A/B Experiments
The text was updated successfully, but these errors were encountered: