Skip to content

fix(terminal): detect new bash commands by history number on bash 3.2 - #52

Merged
arifintahu merged 1 commit into
mainfrom
fix/bash-3.2-command-marks
Nov 17, 2026
Merged

arifintahu merged 1 commit into
mainfrom
fix/bash-3.2-command-marks

Conversation

@arifintahu

Copy link
Copy Markdown
Member

What and why

main CI failed on the macOS job after #51: bash_hook_end_to_end got no OSC 133;E command marks. The macOS runner's bash is /bin/bash 3.2, where $HISTCMD stays at 1 inside PROMPT_COMMAND, so the hook's $HISTCMD != $__ember_hn check never fired.

  • On bash < 4 the hook reads the history number from history 1. Bash 4+ keeps $HISTCMD, so Git Bash pays no extra fork per prompt.
  • Known gap: bash 3.2 cannot mark seeded lines as already saved (history -a/-w/-n/-r variants all tried), so there the restored lines are written back to the history file. The e2e test asserts "seeds stay out of the history file" only on bash >= 4. Only affects choosing /bin/bash on macOS (default shell there is zsh).
  • No CHANGELOG entry: the command-history feature is still under [Unreleased] and does not claim macOS.

Failing run: https://github.com/emberterm/emberterm/actions/runs/43879811129

How you checked it

CI runs only after a merge, so these are checked locally:

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings and cargo test pass (111 passed)
  • pnpm turbo check test build (181 Vitest tests passed) and pnpm version:check pass
  • Bug fixes have a test that failed before the fix: bash_hook_end_to_end is the test that failed on macOS CI; I reproduced the missing marks with bash 3.2.57 in Docker and confirmed 4 marks on 3.2, 5.2 and 5.3 after the fix
  • No secrets, personal paths or machine names in the diff
  • Docs and CHANGELOG.md updated if behaviour changed (not needed, see above)

Local run was Windows (Git Bash 5.2) only; the macOS job runs after merge.

macOS /bin/bash 3.2 keeps $HISTCMD at 1 inside PROMPT_COMMAND, so the hook
never saw a new command and emitted no OSC 133;E marks. On bash < 4 read
the number from `history 1` instead; newer bash keeps $HISTCMD (no extra
fork per prompt under MSYS).

bash 3.2 cannot mark seeded history lines as saved, so the e2e test only
asserts they stay out of the history file on bash >= 4.
@arifintahu
arifintahu merged commit f425b94 into main Nov 17, 2026
4 checks passed
@arifintahu
arifintahu deleted the fix/bash-3.2-command-marks branch November 17, 2026 04:12
@arifintahu arifintahu mentioned this pull request Nov 17, 2026
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant