diff --git a/src/builtins/read.rs b/src/builtins/read.rs index 374327f69..7051897f3 100644 --- a/src/builtins/read.rs +++ b/src/builtins/read.rs @@ -12,6 +12,7 @@ use crate::env::EnvMode; use crate::env::Environment; use crate::env::READ_BYTE_LIMIT; use crate::env::{EnvVar, EnvVarFlags}; +use crate::input_common::terminal_protocols_disable_ifn; use crate::libc::MB_CUR_MAX; use crate::nix::isatty; use crate::reader::commandline_set_buffer; @@ -243,6 +244,7 @@ fn read_interactive( reader_readline(parser, nchars) }; + terminal_protocols_disable_ifn(); if let Some(line) = mline { *buff = line; if nchars > 0 && nchars < buff.len() { diff --git a/src/builtins/wait.rs b/src/builtins/wait.rs index f49233259..5865317ec 100644 --- a/src/builtins/wait.rs +++ b/src/builtins/wait.rs @@ -165,8 +165,6 @@ pub fn wait(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Opt return STATUS_CMD_OK; } - crate::input_common::terminal_protocols_disable_ifn(); - if w.wopt_index == argc { // No jobs specified. // Note this may succeed with an empty wait list. diff --git a/src/exec.rs b/src/exec.rs index 1e60e539f..299fcb73e 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -72,10 +72,6 @@ pub fn exec_job(parser: &Parser, job: &Job, block_io: IoChain) -> bool { return true; } - if job.entitled_to_terminal() { - crate::input_common::terminal_protocols_disable_ifn(); - } - // Handle an exec call. if job.processes()[0].typ == ProcessType::exec { // If we are interactive, perhaps disallow exec if there are background jobs. diff --git a/src/parser.rs b/src/parser.rs index 12457f037..6014e093d 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -14,6 +14,7 @@ use crate::expand::{ }; use crate::fds::{open_dir, BEST_O_SEARCH}; use crate::global_safety::RelaxedAtomicBool; +use crate::input_common::terminal_protocols_disable_ifn; use crate::io::IoChain; use crate::job_group::MaybeJobId; use crate::operation_context::{OperationContext, EXPANSION_LIMIT_DEFAULT}; @@ -610,6 +611,8 @@ impl Parser { let mut execution_context = ExecutionContext::new(ps.clone(), block_io.clone(), Rc::clone(&line_counter)); + terminal_protocols_disable_ifn(); + // Check the exec count so we know if anything got executed. let prev_exec_count = self.libdata().exec_count; let prev_status_count = self.libdata().status_count; diff --git a/src/reader.rs b/src/reader.rs index 12aa0afee..c787dd51e 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -75,6 +75,7 @@ use crate::history::{ SearchType, }; use crate::input::init_input; +use crate::input_common::terminal_protocols_disable_ifn; use crate::input_common::IN_MIDNIGHT_COMMANDER_PRE_CSI_U; use crate::input_common::{ terminal_protocol_hacks, terminal_protocols_enable_ifn, CharEvent, CharInputStyle, InputData, @@ -5689,6 +5690,9 @@ impl<'a> Reader<'a> { token_range.start += cmdsub_range.start; token_range.end += cmdsub_range.start; + // Wildcard expansion and completion below check for cancellation. + terminal_protocols_disable_ifn(); + // Check if we have a wildcard within this string; if so we first attempt to expand the // wildcard; if that succeeds we don't then apply user completions (#8593). let mut wc_expanded = WString::new(); diff --git a/src/wildcard.rs b/src/wildcard.rs index f4bea7c33..a84754ac0 100644 --- a/src/wildcard.rs +++ b/src/wildcard.rs @@ -439,7 +439,6 @@ mod expander { use crate::{ common::scoped_push, path::append_path_component, - threads::is_main_thread, wutil::{dir_iter::DirIter, normalize_path, DevInode}, }; @@ -583,10 +582,6 @@ mod expander { } } - if is_main_thread() { - crate::input_common::terminal_protocols_disable_ifn(); - } - // return "." and ".." entries if we're doing completions let Ok(mut dir) = self.open_dir( base_dir, /* return . and .. */ diff --git a/tests/pexpects/read.py b/tests/pexpects/read.py index b8adc04b4..4eabb531e 100644 --- a/tests/pexpects/read.py +++ b/tests/pexpects/read.py @@ -56,12 +56,12 @@ print_var_contents("foo", "bar") # read -c (see #8633) sendline(r"read -c init_text somevar && echo $somevar") -expect_re(r"\r\n?read> init_text$") +expect_re(r"\r\n?.*read> init_text") sendline("someval") expect_prompt("someval\r\n") sendline(r"read --command='some other text' somevar && echo $somevar") -expect_re(r"\r\n?read> some other text$") +expect_re(r"\r\n?.*read> some other text") sendline("another value") expect_prompt("another value\r\n") diff --git a/tests/pexpects/signals.py b/tests/pexpects/signals.py index 14bfa8111..9387ae331 100644 --- a/tests/pexpects/signals.py +++ b/tests/pexpects/signals.py @@ -48,7 +48,7 @@ expect_prompt() sendline("function postexec --on-event fish_postexec; echo fish_postexec spotted; end") expect_prompt() sendline("read") -expect_re(r"\r\n?read> $", timeout=10) +expect_re(r"\r\n?.*read> .*", timeout=10) sleep(0.1) os.kill(sp.spawn.pid, signal.SIGINT) expect_str("fish_postexec spotted", timeout=10)