-
Notifications
You must be signed in to change notification settings - Fork 95
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
Update DEBUG preserving behavior to fire on all DEBUG traps, not just preexec events #54
Conversation
Tried running this locally and looks like we'll invoke the original function more often than originally intended. Is this an issue? Wondering if this is simply a side effect of bash-preexec in general. What do you think? elementz@Kashmir:~/git/bash-preexec (dimo414-master)$ trap
trap -- '' SIGTSTP
trap -- '' SIGTTIN
trap -- '' SIGTTOU
elementz@Kashmir:~/git/bash-preexec (dimo414-master)$ trap 'echo "From trap"' DEBUG
elementz@Kashmir:~/git/bash-preexec (dimo414-master)$ ls
From trap
bash-preexec.sh LICENSE.md README.md test test.sh
elementz@Kashmir:~/git/bash-preexec (dimo414-master)$ pwd
From trap
/home/elementz/git/bash-preexec
elementz@Kashmir:~/git/bash-preexec (dimo414-master)$ source bash-preexec.sh
From trap
From trap
From trap
From trap
From trap
From trap
From trap
From trap
From trap
From trap
From trap
# Notice the additional invocations here
elementz@Kashmir:~/git/bash-preexec (dimo414-master)$ pwd
From trap
/home/elementz/git/bash-preexec
From trap
From trap
elementz@Kashmir:~/git/bash-preexec (dimo414-master)$ echo
From trap
From trap
From trap |
I think this is an expected side-effect - I can replicate the same thing without my change by manually tweaking the DEBUG trap:
One of the extra traps is triggered by the |
Thanks for following up @dimo414. I think this preserves the integrity of the trap, but I'm not sure this is the best experience. If we weren't manipulating the Put another way, do you think invoking @dimo414 Do you have any examples of |
Good question - I agree that most people using the DEBUG trap in an interactive session probably want preexec semantics and have to jump through hoops to get it (since they're not using this library). However, we can't know that's what was intended. It's true that installing bash-preexec potentially changes the number of times the original DEBUG trap would be triggered, but anyone implementing their own DEBUG trap has to account for the possibility of the trap firing at other times than just preexec, or their implementation is simply wrong.
I don't know if I agree with that - in particular the DEBUG trap fires twice for
I don't have a concrete use-case for needing this distinction or otherwise needing to preserve the DEBUG semantics at the moment, but it does seem a bit odd to me not to do so. That said, maybe it's better to hold off on this fix for now? |
I have a DEBUG trap that sets the title of my terminal window to |
Why has this been closed? Was it intentional? I still expect the behavior of existing DEBUG traps, whose fix was supposed to be here. |
Fixes issue #52.