mirror of
https://github.com/ajeetdsouza/zoxide.git
synced 2026-11-06 20:57:56 -04:00
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 <Mathjk@users.noreply.github.com>
This commit is contained in:
+4
-3
@@ -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<()> {
|
||||
|
||||
Reference in New Issue
Block a user