Skip to content

Shell integration breaks bash PROMPT_COMMAND that depends on exit status

Bug report

Thanks for filing an issue! Please answer the questions below so I can help you.

  • iTerm2 version: Build 3.4.15
  • OS version: macOS 12.3 (21E230)
  • Attach [com.googlecode.iterm2.plist](/uploads/81a632c36d547c8cfe8785ec356e5a1c/com.googlecode.iterm2.plist) here (drag-drop from finder into this window)

Detailed steps to reproduce the problem

  1. Define a bash PROMPT_COMMAND that changes the prompt depending on the exit status of the previous command
  2. Install iTerm2's shell integration

What happened

The PROMPT_COMMAND thinks every command exited with a status of 0.

What should have happened

The PROMPT_COMMAND should receive the original exit status of the command, even after iTerm2 shell integration is installed.

This is due to a bug in bash-preexec. I have submitted a fix here: https://github.com/rcaloras/bash-preexec/pull/131 - once that gets reviewed and merged, please update your bash-preexec to fix the problem.