Repository navigation
fix: use environment variables to prevent command_not_found from recursing - #11090
Conversation
When the command_not_found hook is entered, we add an overlay for context. If an unknown command is encountered and the command_not_found context overlay is already present, it implies a command in the hook closure is also not found.
|
I'm not a 100% satisfied with this. The user or a script could create an overlay called |
|
@kubouch any ideas about this one? Seems like we've missed responding to it. Sorry @lavafroth! |
|
Oops, sorry about the miss! The overlay solution is a hack, I would avoid it. How about adding an environment variable when running the hook, then checking for it? |
|
@kubouch, that's correct. The overlay solution is definitely a hack. The only proper ways I can see this done is either using an environment variable as you mentioned or having some global state. |
|
I think environment variable is OK to use in this scenario, no need for a global state IMO. |
|
I've updated the code. Should be working as expected.
|
|
OK, looks good, let's try it! |
Description
When the
command_not_foundhook is entered, we set an environment variable for context. If an unknown command is encountered and thecommand_not_foundcontext environment variable is already present, it implies a command in the hook closure is also not found. We stop the recursion right there.User-Facing Changes
Incorrect
command_not_foundhooks can be caught without panicking.Tests + Formatting
Tests are passing.
After Submitting