From 7ffe023735241b8cc635d64307946149767c6b4d Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 6 Apr 2024 10:54:31 +0200 Subject: [PATCH] builtin read: enable terminal protocols again It's not clear whether builtin read should be able to do everything that the normal prompt does but I guess we haven't found a problem yet. Given that read could be used to read a single character at a type, it's a bit odd to toggle terminal protocols all the time. But that's not the typical case (at least not for when stdin is a TTY), and it seems fine. Teste with bind ctrl-4 'echo yay' Regressed in 8164855b7 (Disable terminal protocols throughout evaluation, 2024-04-02). --- src/builtins/read.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/builtins/read.rs b/src/builtins/read.rs index f397a4ec6..423bb2ec7 100644 --- a/src/builtins/read.rs +++ b/src/builtins/read.rs @@ -16,7 +16,6 @@ use crate::input_common::terminal_protocols_enable_scoped; use crate::libc::MB_CUR_MAX; use crate::nix::isatty; use crate::reader::commandline_set_buffer; -use crate::reader::reader_current_data; use crate::reader::ReaderConfig; use crate::reader::{reader_pop, reader_push, reader_readline}; use crate::tokenizer::Tokenizer; @@ -592,8 +591,7 @@ pub fn read(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Opt let stream_stdin_is_a_tty = isatty(streams.stdin_fd); // Enable terminal protocols if noninteractive. - let _terminal_protocols = (stream_stdin_is_a_tty && reader_current_data().is_none()) - .then(terminal_protocols_enable_scoped); + let _terminal_protocols = stream_stdin_is_a_tty.then(terminal_protocols_enable_scoped); // Normally, we either consume a line of input or all available input. But if we are reading a // line at a time, we need a middle ground where we only consume as many lines as we need to