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.
This commit is contained in:
Fabian Homborg 2019-04-05 12:29:57 +02:00
parent 2e6264558c
commit 2a3677b386
2 changed files with 3 additions and 12 deletions

View File

@ -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) {

View File

@ -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();