From 9a6d2d4cecb9b31c989fc9db4f15b3f7be48333a Mon Sep 17 00:00:00 2001 From: jk <1835947594@qq.com> Date: Fri, 2 Oct 2026 04:14:48 +0800 Subject: [PATCH] fix: handle broken pipe in query --interactive (#1314) query_interactive printed the fzf selection with bare print! macros, which panic on EPIPE. Use the pipe_exit convention introduced for broken pipes in #137 like the rest of the command already does. The final flush makes the error surface deterministically even if stdout buffering would otherwise defer the failed write to process exit. Co-authored-by: Mathjk --- src/cmd/query.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cmd/query.rs b/src/cmd/query.rs index 6539c2e..4b03dff 100644 --- a/src/cmd/query.rs +++ b/src/cmd/query.rs @@ -43,13 +43,14 @@ impl Query { } }; + let stdout = &mut io::stdout(); if self.score { - print!("{selection}"); + write!(stdout, "{selection}").pipe_exit("stdout")?; } else { let path = selection.get(7..).context("could not read selection from fzf")?; - print!("{path}"); + write!(stdout, "{path}").pipe_exit("stdout")?; } - Ok(()) + stdout.flush().pipe_exit("stdout") } fn query_list(&self, stream: &mut Stream, now: Epoch) -> Result<()> {