7
7
8
8
use clap:: { crate_version, Arg , ArgAction , ArgMatches , Command } ;
9
9
use std:: ffi:: OsString ;
10
- use std:: io:: { self , BufWriter , ErrorKind , Read , Seek , SeekFrom , Write } ;
10
+ use std:: io:: { self , ErrorKind , Read , Seek , SeekFrom , Write } ;
11
11
use std:: num:: TryFromIntError ;
12
12
use thiserror:: Error ;
13
13
use uucore:: display:: Quotable ;
@@ -18,9 +18,6 @@ use uucore::{format_usage, help_about, help_usage, show};
18
18
19
19
const BUF_SIZE : usize = 65536 ;
20
20
21
- /// The capacity in bytes for buffered writers.
22
- const BUFWRITER_CAPACITY : usize = 16_384 ; // 16 kilobytes
23
-
24
21
const ABOUT : & str = help_about ! ( "head.md" ) ;
25
22
const USAGE : & str = help_usage ! ( "head.md" ) ;
26
23
@@ -254,6 +251,7 @@ where
254
251
let mut stdout = stdout. lock ( ) ;
255
252
256
253
io:: copy ( & mut reader, & mut stdout) ?;
254
+ stdout. flush ( ) ?;
257
255
258
256
Ok ( ( ) )
259
257
}
@@ -263,11 +261,10 @@ fn read_n_lines(input: &mut impl std::io::BufRead, n: u64, separator: u8) -> std
263
261
let mut reader = take_lines ( input, n, separator) ;
264
262
265
263
// Write those bytes to `stdout`.
266
- let stdout = std:: io:: stdout ( ) ;
267
- let stdout = stdout. lock ( ) ;
268
- let mut writer = BufWriter :: with_capacity ( BUFWRITER_CAPACITY , stdout) ;
264
+ let mut stdout = std:: io:: stdout ( ) ;
269
265
270
- io:: copy ( & mut reader, & mut writer) ?;
266
+ io:: copy ( & mut reader, & mut stdout) ?;
267
+ stdout. flush ( ) ?;
271
268
272
269
Ok ( ( ) )
273
270
}
0 commit comments