mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 21:33:09 +00:00
Handle exit
in keybindings immediately
This simply checks if the parser requested exit after running any binding scripts (in read_normal_chars). I think this means we no longer need the `exit` bind function. Fixes #7967.
This commit is contained in:
parent
28b17879c7
commit
202e5e53d5
2 changed files with 21 additions and 0 deletions
|
@ -3932,6 +3932,11 @@ maybe_t<wcstring> reader_data_t::readline(int nchars_or_0) {
|
|||
}
|
||||
}
|
||||
|
||||
// If we ran `exit` anywhere, exit.
|
||||
exit_loop_requested |= parser().libdata().exit_current_script;
|
||||
parser().libdata().exit_current_script = false;
|
||||
if (exit_loop_requested) continue;
|
||||
|
||||
if (!event_needing_handling || event_needing_handling->is_check_exit()) {
|
||||
continue;
|
||||
} else if (event_needing_handling->is_eof()) {
|
||||
|
|
|
@ -317,3 +317,19 @@ sendline('bind \cz "echo bound ctrl-z"')
|
|||
expect_prompt()
|
||||
send("\x1A")
|
||||
expect_str("bound ctrl-z")
|
||||
|
||||
# Check that the builtin version of `exit` works
|
||||
# (for obvious reasons this MUST BE LAST)
|
||||
sendline('function myexit; echo exit; exit; end; bind \cz myexit')
|
||||
expect_prompt()
|
||||
send("\x1A")
|
||||
expect_str("exit")
|
||||
|
||||
for t in range(0, 5):
|
||||
if not sp.spawn.isalive():
|
||||
break
|
||||
# This is cheesy, but on CI with thread-sanitizer this can be slow enough that the process is still running, so we sleep for a bit.
|
||||
time.sleep(1)
|
||||
else:
|
||||
print("Fish did not exit via binding!")
|
||||
sys.exit(1)
|
||||
|
|
Loading…
Reference in a new issue