vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Fix Simplify bash PROMPT_COMMAND handling commit

Open emeric-martineau opened this issue 3 years ago • 2 comments

Fix @Tyriar commit dfc99af92ae923841caa055260deac9b61570725 Simplify bash PROMPT_COMMAND handling.

What's happend ?

I use a modified PS1 for bash prompt:

function _update_ps1() {
    PS1="$(/usr/local/bin/powerline-go -error $? -jobs $(jobs -p | /usr/bin/wc -l) -modules "user,host,cwd,perms,git,hg,jobs,exit,root")"
}

if [ "$TERM" != "linux" ] && [ -f "/usr/local/bin/powerline-go" ]; then
    PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

It works fine without VSCode terminal integration. $? return last exit code of command.

But, since VSCode 1.7.0, $? return value of [[ ${#__vsc_original_prompt_command[@]} -gt 1 ]] line (line 161).

In my case, $? return always error.

Debug trace:

+ builtin unset VSCODE_INJECTION
...
++ __vsc_status=0
++ [[ 1 -gt 1 ]]
++ eval '_update_ps1; '
+++ _update_ps1
+++++ /usr/bin/wc -l
+++++ jobs -p
++++ /usr/local/bin/powerline-go -error 1 -jobs 0 -modules user,host,cwd,perms,git,hg,jobs,exit,root
+++ PS1='\[\e[38;5;250m\]\[\e[48;5;240m\] vagrant \[\e[48;5;238m\]\[\e[38;5;240m\]\[\e[0m\]\[\e[38;5;250m\]\[\e[48;5;238m\] mv-ulm \[\e[48;5;31m\]\[\e[38;5;238m\]\[\e[0m\]\[\e[38;5;15m\]\[\e[48;5;31m\] ~ \[\e[48;5;161m\]\[\e[38;5;31m\]\[\e[0m\]\[\e[38;5;15m\]\[\e[48;5;161m\] ERROR \[\e[48;5;161m\]\[\e[38;5;161m\]\[\e[0m\]\[\e[38;5;15m\]\[\e[48;5;161m\] \$ \[\e[0m\]\[\e[38;5;161m\]\[\e[0m\] '

In my case, $? return value of [[ 1 -gt 1 ]].

fixes https://github.com/microsoft/vscode/issues/157206

emeric-martineau avatar Aug 09 '22 12:08 emeric-martineau

related https://github.com/microsoft/vscode/issues/157206

meganrogge avatar Aug 09 '22 17:08 meganrogge

Should fix #157294

BMBurstein avatar Aug 10 '22 11:08 BMBurstein