mirror of
https://github.com/rcaloras/bash-preexec.git
synced 2026-11-03 22:49:41 -09:00
If PROMPT_COMMAND contains unrelated commands before installing bash-preexec, then these unrelated commands may trigger `__bp_preexec_invoke_exec`, which causes interactive mode marker to be unset. This causes preexec to be missed for the first interactive command, since bash-preexec assumes that we are still not interactive. Example of what can trigger such behavior: on Arch Linux in a login shell /etc/profile.d/80-systemd-osc-context.sh causes `__systemd_osc_context_precmdline` to be added to PROMPT_COMMAND, and `__systemd_osc_context_precmdline` trips `__bp_preexec_interactive_mode`. This patch avoids the issue by appending our initialization hook as the last element of PROMPT_COMMAND in Bash >= 5.1, instead of appending the hook to the first element of PROMPT_COMMAND. |
||
|---|---|---|
| .. | ||
| bash-preexec.bats | ||
| include-test.bats | ||
| README.md | ||
Testing bash-preexec
Note on test conditions
When writing test conditions, use [ ... ] instead of [[ ... ]] since the
former are supported by Bats on Bash versions before 4.1. In particular, macOS
uses Bash 3.2, and [[ ... ]] tests always pass on macOS.
In some cases, you may want to use a feature unique to [[ ... ]] such as
pattern matching ([[ $name = a* ]]) or regular expressions ([[ $(date) =~ ^Fri\ ...\ 13 ]]). In those cases, use the following pattern to replace “bare”
[[ ... ]].
[[ ... ]] || return 1
References: