Skip to content

Commit d23fc20

Browse files
authored
dircolors >/dev/full panics (#10948)
1 parent fb4b55e commit d23fc20

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/uu/dircolors/src/dircolors.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::env;
1010
use std::ffi::OsString;
1111
use std::fmt::Write as _;
1212
use std::fs::File;
13-
use std::io::{BufRead, BufReader};
13+
use std::io::{BufRead, BufReader, Write, stdout};
1414
use std::path::Path;
1515

1616
use clap::{Arg, ArgAction, Command};
@@ -150,7 +150,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
150150
));
151151
}
152152

153-
println!("{}", generate_dircolors_config());
153+
writeln!(stdout(), "{}", generate_dircolors_config())?;
154154
return Ok(());
155155
}
156156

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

179179
let result;
180180
if files.is_empty() {
181-
println!("{}", generate_ls_colors(&out_format, ":"));
181+
writeln!(stdout(), "{}", generate_ls_colors(&out_format, ":"))?;
182182
return Ok(());
183183
/*
184184
// Check if data is being piped into the program
185185
if std::io::stdin().is_terminal() {
186186
// No data piped, use default behavior
187-
println!("{}", generate_ls_colors(&out_format, ":"));
187+
writeln!(stdout(), "{}", generate_ls_colors(&out_format, ":"))?;
188188
return Ok(());
189189
} else {
190190
// Data is piped, process the input from stdin
@@ -230,7 +230,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
230230

231231
match result {
232232
Ok(s) => {
233-
println!("{s}");
233+
writeln!(stdout(), "{s}")?;
234234
Ok(())
235235
}
236236
Err(s) => Err(USimpleError::new(1, s)),

0 commit comments

Comments
 (0)