mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00: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:
parent
158754f4ab
commit
26aa1f346e
1 changed files with 1 additions and 1 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue