Skip to content

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

@JeffFaer

Description

@JeffFaer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions