From 2a3677b38659835858c9d557e7d920630bfbcbb8 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 5 Apr 2019 12:29:57 +0200 Subject: [PATCH] Stop setting term-modes early This set the term modes to the shell-modes, including disabling ICRNL (translating \cm to \cj) and echo. The rationale given was that `reader_interactive_init()` would only be called >= 250ms later, which I _highly_ doubt considering fish's total startup time is 8ms for me. The main idea was that this would stop programs like tmuxinator that send shortcuts early from failing _iff_ the shortcut was \cj, which also seems quite unusual. This works both with `rm -i` and `read` in config.fish, because `read` explicitly calls `reader_push`, which then initializes the shell modes. The real fix would involve reordering our init so we set up the modesetting first, but that's quite involved and the remaining issue should barely happen, while it's fairly common to have issues with a prompt in config.fish, and the workaround for the former is simpler, so let's leave it for now. Partially reverts #2578. Fixes #2980. --- src/fish_key_reader.cpp | 3 +++ src/reader.cpp | 12 ------------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/fish_key_reader.cpp b/src/fish_key_reader.cpp index ba688b4e7..36fdd0fa8 100644 --- a/src/fish_key_reader.cpp +++ b/src/fish_key_reader.cpp @@ -286,6 +286,9 @@ static void setup_and_process_keys(bool continuous_mode) { proc_push_interactive(1); env_init(); reader_init(); + // We need to set the shell-modes for ICRNL, + // in fish-proper this is done once a command is run. + tcsetattr(STDIN_FILENO, TCSANOW, &shell_modes); install_our_signal_handlers(); if (continuous_mode) { diff --git a/src/reader.cpp b/src/reader.cpp index acdd9ad3f..aa800efe1 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -1001,18 +1001,6 @@ void reader_init() { shell_modes.c_cc[VMIN] = 1; shell_modes.c_cc[VTIME] = 0; - // We don't use term_steal because this can fail if fd 0 isn't associated with a tty and this - // function is run regardless of whether stdin is tied to a tty. This is harmless in that case. - // We do it unconditionally because disabling ICRNL mode (see above) needs to be done at the - // earliest possible moment. Doing it here means it will be done within approximately 1 ms of - // the start of the shell rather than 250 ms (or more) when reader_interactive_init is - // eventually called. - // - // TODO: Remove this condition when issue #2315 and #1041 are addressed. - if (is_interactive_session) { - tcsetattr(STDIN_FILENO, TCSANOW, &shell_modes); - } - // We do this not because we actually need the window size but for its side-effect of correctly // setting the COLUMNS and LINES env vars. get_current_winsize();