Skip to content
Merged
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
10 changes: 5 additions & 5 deletions src/uu/dircolors/src/dircolors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::env;
use std::ffi::OsString;
use std::fmt::Write as _;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::io::{BufRead, BufReader, Write, stdout};
use std::path::Path;

use clap::{Arg, ArgAction, Command};
Expand Down Expand Up @@ -150,7 +150,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
));
}

println!("{}", generate_dircolors_config());
writeln!(stdout(), "{}", generate_dircolors_config())?;
return Ok(());
}

Expand Down Expand Up @@ -178,13 +178,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {

let result;
if files.is_empty() {
println!("{}", generate_ls_colors(&out_format, ":"));
writeln!(stdout(), "{}", generate_ls_colors(&out_format, ":"))?;
return Ok(());
/*
// Check if data is being piped into the program
if std::io::stdin().is_terminal() {
// No data piped, use default behavior
println!("{}", generate_ls_colors(&out_format, ":"));
writeln!(stdout(), "{}", generate_ls_colors(&out_format, ":"))?;
return Ok(());
} else {
// Data is piped, process the input from stdin
Expand Down Expand Up @@ -230,7 +230,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {

match result {
Ok(s) => {
println!("{s}");
writeln!(stdout(), "{s}")?;
Ok(())
}
Err(s) => Err(USimpleError::new(1, s)),
Expand Down
Loading