mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
ls: only print colors if stdout is a tty
Previously if no --color argument was input, we would always print colors in the output. This breaks `configure` scripts which run `ls` and then compare the output against what they expect to see, since the left side has ANSI escape sequences and the right side doesn't. Instead, only print escape sequences if a TTY is present, or if `--color=always` is specified. Fixes #1638.
This commit is contained in:
committed by
Sylvestre Ledru
parent
158754f4ab
commit
26aa1f346e
+1
-1
@@ -622,7 +622,7 @@ fn display_file_name(
|
||||
let mut width = UnicodeWidthStr::width(&*name);
|
||||
|
||||
let color = match options.opt_str("color") {
|
||||
None => true,
|
||||
None => stdout_isatty(),
|
||||
Some(val) => match val.as_ref() {
|
||||
"always" | "yes" | "force" => true,
|
||||
"auto" | "tty" | "if-tty" => atty::is(atty::Stream::Stdout),
|
||||
|
||||
Reference in New Issue
Block a user