mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
wc: print counts for each file as soon as computed
Change the behavior of `wc` to print the counts for a file as soon as it is computed, instead of waiting to compute the counts for all files before writing any output to `stdout`. The new behavior matches the behavior of GNU `wc`. The old behavior looked like this (the word "hello" is entered on `stdin`): $ wc emptyfile.txt - hello 0 0 0 emptyfile.txt 1 1 6 1 1 6 total The new behavior looks like this: $ wc emptyfile.txt - 0 0 0 emptyfile.txt hello 1 1 6 1 1 6 total
This commit is contained in:
parent
73fb426b2b
commit
4521aa2659
1 changed files with 1 additions and 5 deletions
|
@ -373,7 +373,6 @@ fn wc(inputs: Vec<Input>, settings: &Settings) -> Result<(), u32> {
|
||||||
let max_width = max_width(&inputs);
|
let max_width = max_width(&inputs);
|
||||||
|
|
||||||
let mut total_word_count = WordCount::default();
|
let mut total_word_count = WordCount::default();
|
||||||
let mut results = vec![];
|
|
||||||
|
|
||||||
let num_inputs = inputs.len();
|
let num_inputs = inputs.len();
|
||||||
|
|
||||||
|
@ -384,10 +383,7 @@ fn wc(inputs: Vec<Input>, settings: &Settings) -> Result<(), u32> {
|
||||||
WordCount::default()
|
WordCount::default()
|
||||||
});
|
});
|
||||||
total_word_count += word_count;
|
total_word_count += word_count;
|
||||||
results.push(word_count.with_title(input.to_title()));
|
let result = word_count.with_title(input.to_title());
|
||||||
}
|
|
||||||
|
|
||||||
for result in &results {
|
|
||||||
if let Err(err) = print_stats(settings, &result, max_width) {
|
if let Err(err) = print_stats(settings, &result, max_width) {
|
||||||
show_warning!(
|
show_warning!(
|
||||||
"failed to print result for {}: {}",
|
"failed to print result for {}: {}",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue