fix(bash): fix preexec
of child Bash session started by enter_accept
#2558
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that if a new child Bash session is started by
enter_accept
, thepreexec
hook provided by bash-preexec is not triggered at all. This is because the child Bash session inherits the environment variableREADLINE_POINT
of the parent shell session, andbash-preexec
considers we are still processing the Atuin menu even when a new user command is processed inside the child Bash session.How to reproduce the issue
Consider the following bashrc:
With the current
main
branch, we first start a new child session by manually typing the commandbash
and running it:This registers the history entry "bash" in Atuin's database. Any problems don't happen so far. Then, we next press the keys upupupenter to select the entry "bash" and execute it through the
enter_accept
feature.Solution
In this PR, the problem is solved by removing the export attribute of
READLINE_POINT
andREADLINE_LINE
before running the user command withenter_accept
. See the code comments added in this PR for details.Checks