Shell integration breaks custom bash PROMPT_COMMAND using exit status
- iTerm2 version: Build 3.4.19
- OS version: macOS 13.4.1 (22F2083)
- Bash version: 5.2.15(1)-release
- com.googlecode.iterm2.plist
Detailed steps to reproduce the problem:
- In .bashrc, create
prompt_func() { local EXIT=$? ; PS1="$EXIT" }
and setPROMPT_COMMAND="prompt_func${PROMPT_COMMAND:+; ${PROMPT_COMMAND}}"
- Install iTerm2's shell integration
What happened: The PROMPT_COMMAND thinks every command exits with a status of 0 (so every prompt is 0 even if the previous command failed).
What should have happened: The PROMPT_COMMAND should receive the correct exit status, so for example if one types a nonexistent command like blahblah
and hits enter, the next prompt should show 127
.
Edited by Winston Tsai