mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Use external mode for term when running key bindings
Prior to this fix, when key binding is a script command (i.e. not a readline command), fish would run that key binding using fish's shell tty modes. Switch to using the external tty modes. This re-fixes issue #2214.
This commit is contained in:
parent
21e2b39fa8
commit
5f16a299a7
@ -113,6 +113,23 @@ static void print_ignored_signals() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_stop_cont() {
|
||||||
|
signal(SIGTSTP, [](int) {
|
||||||
|
write(STDOUT_FILENO, "SIGTSTP\n", strlen("SIGTSTP\n"));
|
||||||
|
kill(getpid(), SIGSTOP);
|
||||||
|
});
|
||||||
|
signal(SIGCONT, [](int) {
|
||||||
|
write(STDOUT_FILENO, "SIGCONT\n", strlen("SIGCONT\n"));
|
||||||
|
});
|
||||||
|
char buff[1];
|
||||||
|
for (;;) {
|
||||||
|
if (read(STDIN_FILENO, buff, sizeof buff) >= 0) {
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static void show_help();
|
static void show_help();
|
||||||
|
|
||||||
/// A thing that fish_test_helper can do.
|
/// A thing that fish_test_helper can do.
|
||||||
@ -142,6 +159,7 @@ static fth_command_t s_commands[] = {
|
|||||||
"Print to stdout the name(s) of blocked signals"},
|
"Print to stdout the name(s) of blocked signals"},
|
||||||
{"print_ignored_signals", print_ignored_signals,
|
{"print_ignored_signals", print_ignored_signals,
|
||||||
"Print to stdout the name(s) of ignored signals"},
|
"Print to stdout the name(s) of ignored signals"},
|
||||||
|
{"print_stop_cont", print_stop_cont, "Print when we get SIGTSTP and SIGCONT, exiting on input"},
|
||||||
{"help", show_help, "Print list of fish_test_helper commands"},
|
{"help", show_help, "Print list of fish_test_helper commands"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2720,11 +2720,14 @@ struct readline_loop_state_t {
|
|||||||
|
|
||||||
/// Run a sequence of commands from an input binding.
|
/// Run a sequence of commands from an input binding.
|
||||||
void reader_data_t::run_input_command_scripts(const wcstring_list_t &cmds) {
|
void reader_data_t::run_input_command_scripts(const wcstring_list_t &cmds) {
|
||||||
|
// Need to donate/steal the tty - see #2214.
|
||||||
|
term_donate(outputter_t::stdoutput());
|
||||||
auto last_statuses = parser().get_last_statuses();
|
auto last_statuses = parser().get_last_statuses();
|
||||||
for (const wcstring &cmd : cmds) {
|
for (const wcstring &cmd : cmds) {
|
||||||
parser().eval(cmd, io_chain_t{});
|
parser().eval(cmd, io_chain_t{});
|
||||||
}
|
}
|
||||||
parser().set_last_statuses(std::move(last_statuses));
|
parser().set_last_statuses(std::move(last_statuses));
|
||||||
|
term_steal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read normal characters, inserting them into the command line.
|
/// Read normal characters, inserting them into the command line.
|
||||||
|
@ -43,3 +43,31 @@ expect_prompt("has stopped")
|
|||||||
sendline("fg")
|
sendline("fg")
|
||||||
sleep(0.1) # allow tty to transfer
|
sleep(0.1) # allow tty to transfer
|
||||||
send("\x03") # control-c to cancel it
|
send("\x03") # control-c to cancel it
|
||||||
|
|
||||||
|
expect_prompt()
|
||||||
|
sendline("jobs")
|
||||||
|
expect_prompt("jobs: There are no jobs")
|
||||||
|
|
||||||
|
# Regression test for #2214: foregrounding from a key binding works!
|
||||||
|
sendline(r"bind \cr 'fg >/dev/null 2>/dev/null'")
|
||||||
|
expect_prompt()
|
||||||
|
sendline("$fish_test_helper print_stop_cont");
|
||||||
|
sleep(0.2)
|
||||||
|
|
||||||
|
send("\x1A") # ctrl-z
|
||||||
|
expect_prompt("SIGTSTP")
|
||||||
|
sleep(0.1)
|
||||||
|
send("\x12") # ctrl-r, placing fth in foreground
|
||||||
|
expect_str("SIGCONT")
|
||||||
|
|
||||||
|
# Do it again.
|
||||||
|
send("\x1A")
|
||||||
|
expect_str("SIGTSTP")
|
||||||
|
sleep(0.1)
|
||||||
|
send("\x12")
|
||||||
|
expect_str("SIGCONT")
|
||||||
|
|
||||||
|
# End fth by sending it anything.
|
||||||
|
send("\x12")
|
||||||
|
sendline("derp")
|
||||||
|
expect_prompt()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user