Skip to content
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

Preserved DEBUG traps should be invoked every time, not just on preexec #52

Open
dimo414 opened this issue Sep 8, 2017 · 2 comments
Open
Assignees

Comments

@dimo414
Copy link
Collaborator

dimo414 commented Sep 8, 2017

A coworker pointed out that that the fix to #39 doesn't properly preserve the behavior of the DEBUG trap, because preexec only triggers on interactive prompts, whereas before installation the command was triggered on every DEBUG event.

I think this can be fixed by simply moving the old DEBUG trap out of preexec_functions and instead eval-ing it at the beginning of __bp_preexec_invoke_exec - before the short-circuiting checks are made.

The only problem with this is it makes it difficult for someone to clean up the old trap - it's no longer in the trap itself nor in the preexec / preexec_functions, but some other variable. It's simple enough to document that (e.g. "The old DEBUG trap will be preserved in a bp_prior_debug_trap variable") but that widens the API surface and might be abused.

I'll prepare a patch, but I wanted to get some opinions on the approach first.

@rcaloras
Copy link
Owner

@dimo414 interesting observation. Since the original implementation simply overwrote the existing DEBUG trap I think anything is really an improvement here :)

I'm in favor of having a variable preserving the contents of the prior debug trap and invoked how you spec'd. Although it widens the API it's definitely a better experience. It does make things a little more complicated, but if we want to support legit preservation it's worth the compromise 👍

@rcaloras
Copy link
Owner

Assigning over! As always thanks for the contributions 💯 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants