Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let max_count = matches.get_one::<u64>("max_count").copied();
let byte_offset = matches.get_flag("byte_offset");
let line_number = matches.get_flag("line_number");
let line_buffered = matches.get_flag("line_buffered");
let stdout_is_terminal = std::io::stdout().is_terminal();
let line_buffered = matches.get_flag("line_buffered") || stdout_is_terminal;
let with_filename = matches.get_flag("with_filename");
let no_filename = matches.get_flag("no_filename");
let label = matches
Expand Down Expand Up @@ -391,7 +392,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
ColorMode::Never => false,
// On Windows, an unset TERM allows color support, matching anstyle-query.
ColorMode::Auto => {
std::io::stdout().is_terminal()
stdout_is_terminal
&& match std::env::var_os("TERM") {
Some(term) => term != "dumb",
None => cfg!(windows),
Expand Down
2 changes: 1 addition & 1 deletion src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl<'a> OutputWriter<'a> {
}
}

/// Flush in `--line-buffered` mode.
/// Flush for terminal output or explicit `--line-buffered` mode.
fn maybe_flush(&mut self) -> io::Result<()> {
if self.config.line_buffered {
self.out.flush()
Expand Down
Loading