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 <ellie@elliehuxtable.com>

---------

Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
This commit is contained in:
Peter Holloway
2024-01-19 11:16:25 +00:00
committed by GitHub
parent 8913d46dab
commit cda135d241

View File

@ -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?;
if stderr().is_terminal() {
eprintln!("{}", item.escape_control());
} else {
eprintln!("{item}");
}
} else {
let list_mode = ListMode::from_flags(self.human, self.cmd_only);