From c73ba1630ec116d0f170940a765538de26ba5ccf Mon Sep 17 00:00:00 2001 From: Dean Li Date: Tue, 15 Jun 2021 21:47:36 +0800 Subject: [PATCH] ls: set show-control-char if stdout is terminal --- src/uu/ls/src/ls.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index dc67d5738..0bffa2e52 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -382,10 +382,11 @@ impl Config { #[allow(clippy::needless_bool)] let show_control = if options.is_present(options::HIDE_CONTROL_CHARS) { false - } else if options.is_present(options::SHOW_CONTROL_CHARS) { + } else if options.is_present(options::SHOW_CONTROL_CHARS) || atty::is(atty::Stream::Stdout) + { true } else { - false // TODO: only if output is a terminal and the program is `ls` + false }; let quoting_style = if let Some(style) = options.value_of(options::QUOTING_STYLE) {