rcaloras / bash-preexec

⚡ preexec and precmd functions for Bash just like Zsh.
MIT License
862 stars 94 forks source link

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

Open JeffFaer opened 6 months ago

JeffFaer commented 6 months ago

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. https://github.com/rcaloras/bash-preexec/blob/1f77dc09356b58b5e2877c1e87158c48c4c377bc/bash-preexec.sh#L330-L336

    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. https://github.com/rcaloras/bash-preexec/blob/1f77dc09356b58b5e2877c1e87158c48c4c377bc/bash-preexec.sh#L245-L250

    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