From cda135d241c7e66d4f371d5c13a4501b1002e4e8 Mon Sep 17 00:00:00 2001 From: Peter Holloway Date: Fri, 19 Jan 2024 11:16:25 +0000 Subject: fix: Print literal control characters to non terminals (#1586) * Print literal control characters to non terminals Previous 'fix' to prevent control sequences being interpreted when they shouldn't have been also prevented them being used when they should have been. This checks if the output is to a terminal (where control sequences shouldn't be interpreted) before escaping control characters. * Update atuin/src/command/client/search.rs Co-authored-by: Ellie Huxtable --------- Co-authored-by: Ellie Huxtable --- atuin/src/command/client/search.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/atuin/src/command/client/search.rs b/atuin/src/command/client/search.rs index 456dc391..a929abd9 100644 --- a/atuin/src/command/client/search.rs +++ b/atuin/src/command/client/search.rs @@ -1,3 +1,5 @@ +use std::io::{stderr, IsTerminal as _}; + use atuin_common::utils::{self, Escapable as _}; use clap::Parser; use eyre::Result; @@ -167,7 +169,11 @@ impl Cmd { if self.interactive { let item = interactive::history(&self.query, settings, db, &history_store).await?; - eprintln!("{}", item.escape_control()); + if stderr().is_terminal() { + eprintln!("{}", item.escape_control()); + } else { + eprintln!("{item}"); + } } else { let list_mode = ListMode::from_flags(self.human, self.cmd_only); -- cgit v1.3.1