fish-shell / fish-shell/fish-shell
Generic binding with command is an infinite loop
- Dominant language
- Rust
- Stars
- 34.2k
- Forks
- 2.4k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 13
Description
As mentioned in #5528, if I do
```fish
bind "" true
```
and press any key, it'll send fish spinning.
This is because, as the code says:
```c++
input_common_next_ch(c);
input_mapping_execute_matching_or_generic(allow_commands);
// Regarding allow_commands, we're in a loop, but if a fish command
// is executed, R_NULL is unread, so the next pass through the loop
// we'll break out and return it.
```
We've read something, but (for reasons I don't understand) we don't want to execute commands yet, so we put an R_NULL at the front of the input queue.
But we stay in the loop, so the next time we read that R_NULL, which isn't bound to anything so we try the generic binding, which has a command, so instead of executing it we put an R_NULL, and then we loop again.
I'm not sure if this was supposed to _return_ R_NULL, as a value, or if R_NULL wasn't supposed to trigger _any_ binding otherwise, or what.
Just changing it to return R_NULL here instead of putting it back doesn't work.
My main problem with fixing this is that I have a very fuzzy idea of what all of this is supposed to _mean_. What's an "R_NULL"? Is that a separator, so that we can't confuse "abc" with "abcd", because it's really "abcR_NULLd"?
Is it a "yield marker", so that we then break out of the loop to go do other things?
Why aren't commands allowed here? When will they be allowed again?
Contributor guide
Assessment
This issue has not been assessed yet.