diff --git a/src/reader.rs b/src/reader.rs index 5067ccbba..098323c43 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -243,7 +243,11 @@ pub(crate) fn initial_query( vars: Option<&dyn Environment>, ) { blocking_query.get_or_init(|| { - let query = if is_dumb() || IN_MIDNIGHT_COMMANDER.load() || IN_DVTM.load() { + let query = if is_dumb() + || IN_MIDNIGHT_COMMANDER.load() + || IN_DVTM.load() + || !isatty(STDOUT_FILENO) + { None } else { // Query for kitty keyboard protocol support. @@ -1525,6 +1529,9 @@ pub(crate) fn blocking_query(&self) -> RefMut<'_, Option> { } pub fn request_cursor_position(&mut self, out: &mut Outputter, q: CursorPositionQuery) { + if !isatty(STDOUT_FILENO) { + return; + } let mut query = self.blocking_query(); assert!(query.is_none()); *query = Some(TerminalQuery::CursorPositionReport(q)); diff --git a/tests/checks/tmux-invocation.fish b/tests/checks/tmux-invocation.fish new file mode 100644 index 000000000..01100371d --- /dev/null +++ b/tests/checks/tmux-invocation.fish @@ -0,0 +1,20 @@ +#RUN: %fish %s +#REQUIRES: command -v tmux + +set -g isolated_tmux_fish_extra_args -C ' + set -g fish (status fish-path) +' +isolated-tmux-start + +# Implicit interactive but output is redirected. +isolated-tmux send-keys \ + '$fish >output' Enter +tmux-sleep +isolated-tmux send-keys \ + 'status is-interactive && printf %s i n t e r a c t i v e \n' Enter \ + C-d +tmux-sleep +# Extract the line where command output starts. +string match