Skip to content

Commit

Permalink
numfmt: fix bug when handling broken pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
sbentmar committed Dec 31, 2022
1 parent 5d15476 commit 6203822
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/uu/numfmt/src/numfmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ where
R: BufRead,
{
let mut lines = input.lines();
lines
.by_ref()
.take(options.header)
.for_each(|line| println!("{}", line.unwrap()));

for line in lines.by_ref().take(options.header) {
match line {
Ok(l) => println!("{}\n", l),
Err(e) => return Err(Box::new(NumfmtError::IoError(e.to_string()))),
};
}

let mut has_failed_flag = false;

Expand Down

0 comments on commit 6203822

Please sign in to comment.