diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 19798c405..84bd499cb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -155,6 +155,7 @@ Interactive improvements - ``read --help`` and friends no longer ignore redirections. This fixes a regression in version 3.1 (:issue:`10274`). - Measuring a command with ``time`` now considers the time taken for command substitution (:issue:`9100`). - ``fish_add_path`` now automatically enables verbose mode when used interactively (in the commandline), in an effort to be clearer about what it does (:issue:`10532`). +- fish no longer adopts TTY modes of failed commands (:issue:`10603`). New or improved bindings ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/reader.rs b/src/reader.rs index 36c87bfbb..7046f63c3 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -3680,8 +3680,10 @@ pub fn term_copy_modes() { } /// Grab control of terminal. -fn term_steal() { - term_copy_modes(); +fn term_steal(copy_modes: bool) { + if copy_modes { + term_copy_modes(); + } while unsafe { libc::tcsetattr(STDIN_FILENO, TCSANOW, &*shell_modes()) } == -1 { if errno().0 == EIO { redirect_tty_output(); @@ -4986,7 +4988,7 @@ fn reader_run_command(parser: &Parser, cmd: &wstr) -> EvalRes { ); } - term_steal(); + term_steal(eval_res.status.is_success()); // Provide value for `status current-command` parser.libdata_mut().status_vars.command = (*PROGRAM_NAME.get().unwrap()).to_owned();