Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preexec doesn't work for no-op command : #153

Open
JeffFaer opened this issue Feb 18, 2024 · 0 comments · May be fixed by #154
Open

preexec doesn't work for no-op command : #153

JeffFaer opened this issue Feb 18, 2024 · 0 comments · May be fixed by #154

Comments

@JeffFaer
Copy link

JeffFaer commented Feb 18, 2024

This might fall into this kind of a situation, and I apologize in advance: https://xkcd.com/1172/


I have a habit of running : specifically to execute preexecs. Today, I updated my version of bash-preexec, and that functionality no longer works.

  1. existing_prompt_command="${existing_prompt_command//$__bp_install_string/:}" # no-op
    existing_prompt_command="${existing_prompt_command//$'\n':$'\n'/$'\n'}" # remove known-token only
    existing_prompt_command="${existing_prompt_command//$'\n':;/$'\n'}" # remove known-token only
    __bp_sanitize_string existing_prompt_command "$existing_prompt_command"
    if [[ "${existing_prompt_command:-:}" == ":" ]]; then
    existing_prompt_command=
    fi

    When bash-preexec installs itself it replaces its install command with a no-op command :. It does not always manage to remove that no-op from the prompt command

  2. if __bp_in_prompt_command "${BASH_COMMAND:-}"; then
    # If we're executing something inside our prompt_command then we don't
    # want to call preexec. Bash prior to 3.1 can't detect this at all :/
    __bp_preexec_interactive_mode=""
    return
    fi

    bash-preexec does not execute preexec commands if it looks like it's executing something from the $PROMPT_COMMAND

I think it should be as simple as adding another prune attempt when we're processing existing_prompt_command. I'll put something together

JeffFaer added a commit to JeffFaer/bash-preexec that referenced this issue Feb 18, 2024
In particular: bash-preexec installs itself by appending
__bp_install_string to $PROMPT_COMMAND. That means that there's a pretty
good change that __bp_install_string will be the last thing in
$PROMPT_COMMAND when __bp_install is invoked.

So there's a pretty good change that the $existing_prompt_command logic
in __bp_install will result in the pre-existing prompt command followed
by `:` and no trailing newline. That situation is not cleaned up by the
two existing special cases.

Fix rcaloras#153
@JeffFaer JeffFaer linked a pull request Feb 18, 2024 that will close this issue
JeffFaer added a commit to JeffFaer/bash-preexec that referenced this issue Feb 18, 2024
In particular: bash-preexec installs itself by appending
__bp_install_string to $PROMPT_COMMAND. That means that there's a pretty
good change that __bp_install_string will be the last thing in
$PROMPT_COMMAND when __bp_install is invoked.

If that happens, the $existing_prompt_command logic in __bp_install will
result in the pre-existing prompt command followed by `:` and no
trailing newline. That situation is not cleaned up by the two existing
 special cases.

Fix rcaloras#153
JeffFaer added a commit to JeffFaer/bash-preexec that referenced this issue Feb 18, 2024
In particular: bash-preexec installs itself by appending
__bp_install_string to $PROMPT_COMMAND. That means that there's a pretty
good change that __bp_install_string will be the last thing in
$PROMPT_COMMAND when __bp_install is invoked.

If that happens, the $existing_prompt_command logic in __bp_install will
result in the pre-existing prompt command followed by `:` and no
trailing newline. That situation is not cleaned up by the two existing
special cases.

Fix rcaloras#153
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 a pull request may close this issue.

1 participant