Open danieltodor opened 1 month ago
Due to the current approach of preexec
using the DEBUG trap, I think there is no way to distinguish the execution of a trap handler from that of a user command. In Bash 5.3+, one might use PS0 + funsub as a more robust implementation of preexec
.
Function added to
preexec_functions
is called twice when it is also added to a SIGINT trap and ^C is pressed.Test code for bash:
Without the
trap
the output has no problem when i press ^C 3 times. The preexec was not called.But when the trap is enabled then the
test
func is called 2 times per each ^C. Once with the last command from preexec, once with the argument from the trap.With a similar test code,
zsh
doesn't have this weird behavior.test
is only called from the trap.The zsh equivalent test code: