Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix command timing on Bash 5.1+ with LP not last
If __lp_set_prompt() was not the last in the PROMPT_COMMAND array, the command that ran right after it would get marked as the start of the command, and the timing would begin then. Obviously, timing the time spent typing a command is not very useful. The fix is to set the AT_PROMPT when the very last PROMPT_COMMAND is ran. This can be checked by looking at the last item in the array. Unfortunately, this will not always work. It is possible to set an entry in the PROMPT_COMMAND array to a compound command, like: `my first command; my second command` In this case, Bash will run the DEBUG trap twice, once with BASH_COMMAND set to "my first command", and the second to "my second command". This will fail our check, meaning the start time is never set. The fix is to check for a BASH_COMMAND with the same ending as the last PROMPT_COMMAND. It is possible this might match early in very special circumstances, but even in that case, the last command will reset everything without problems.
- Loading branch information