mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 18:21:16 -03:00
shell_modes: clear the FLUSHO flag
On macOS, pressing ctrl-o (VDISCARD) before starting fish will discard all terminal output, from shell or its child processes. This breaks querying and seems like something we don't want to support, so maybe disable it? Not sure if term_fix_external_modes needs it too, add it I guess. Fixes #12304
This commit is contained in:
@@ -20,9 +20,9 @@
|
||||
use crate::portable_atomic::AtomicU64;
|
||||
use fish_common::{UTF8_BOM_WCHAR, help_section};
|
||||
use libc::{
|
||||
_POSIX_VDISABLE, ECHO, EINTR, EIO, EISDIR, ENOTTY, EPERM, ESRCH, ICANON, ICRNL, IEXTEN, INLCR,
|
||||
IXOFF, IXON, O_NONBLOCK, O_RDONLY, ONLCR, OPOST, SIGINT, SIGTTIN, STDERR_FILENO, STDIN_FILENO,
|
||||
STDOUT_FILENO, TCSANOW, VMIN, VQUIT, VSUSP, VTIME, c_char,
|
||||
_POSIX_VDISABLE, ECHO, EINTR, EIO, EISDIR, ENOTTY, EPERM, ESRCH, FLUSHO, ICANON, ICRNL, IEXTEN,
|
||||
INLCR, IXOFF, IXON, O_NONBLOCK, O_RDONLY, ONLCR, OPOST, SIGINT, SIGTTIN, STDERR_FILENO,
|
||||
STDIN_FILENO, STDOUT_FILENO, TCSANOW, VMIN, VQUIT, VSUSP, VTIME, c_char,
|
||||
};
|
||||
use nix::fcntl::OFlag;
|
||||
use nix::sys::stat::Mode;
|
||||
@@ -1018,7 +1018,7 @@ pub fn reader_init(will_restore_foreground_pgroup: bool) {
|
||||
{
|
||||
let mut shell_modes = shell_modes();
|
||||
*shell_modes = *tty_modes_for_external_cmds;
|
||||
term_fix_modes(&mut shell_modes);
|
||||
term_fix_shell_modes(&mut shell_modes);
|
||||
}
|
||||
|
||||
drop(tty_modes_for_external_cmds);
|
||||
@@ -4683,7 +4683,7 @@ fn term_fix_oflag(modes: &mut libc::termios) {
|
||||
}
|
||||
|
||||
/// Restore terminal settings we care about, to prevent a broken shell.
|
||||
fn term_fix_modes(modes: &mut libc::termios) {
|
||||
fn term_fix_shell_modes(modes: &mut libc::termios) {
|
||||
modes.c_iflag &= {
|
||||
// disable mapping CR (\cM) to NL (\cJ)
|
||||
!ICRNL
|
||||
@@ -4691,12 +4691,10 @@ fn term_fix_modes(modes: &mut libc::termios) {
|
||||
& !INLCR
|
||||
};
|
||||
modes.c_lflag &= {
|
||||
// turn off echo mode
|
||||
!ECHO
|
||||
// turn off canonical mode
|
||||
& !ICANON
|
||||
// turn off handling of discard and lnext characters
|
||||
& !IEXTEN
|
||||
& !IEXTEN // turn off handling of discard and lnext characters
|
||||
& !FLUSHO
|
||||
};
|
||||
term_fix_oflag(modes);
|
||||
|
||||
@@ -4717,9 +4715,8 @@ fn term_fix_modes(modes: &mut libc::termios) {
|
||||
fn term_fix_external_modes(modes: &mut libc::termios) {
|
||||
term_fix_oflag(modes);
|
||||
// These cause other ridiculous behaviors like input not being shown.
|
||||
modes.c_lflag |= ECHO | ICANON | IEXTEN;
|
||||
modes.c_iflag |= ICRNL;
|
||||
modes.c_iflag &= !INLCR;
|
||||
modes.c_lflag = (modes.c_lflag | ECHO | ICANON | IEXTEN) & !FLUSHO;
|
||||
modes.c_iflag = (modes.c_iflag | ICRNL) & !INLCR;
|
||||
}
|
||||
|
||||
/// Give up control of terminal.
|
||||
|
||||
Reference in New Issue
Block a user