From 88cc6c1141eb9e279b73ce0229bf130885836f35 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 18 Jan 2022 03:31:43 -0500 Subject: simplify --- src/runner/builtins/command.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/runner/builtins/command.rs b/src/runner/builtins/command.rs index e3a3fce..c0d3a84 100644 --- a/src/runner/builtins/command.rs +++ b/src/runner/builtins/command.rs @@ -199,21 +199,13 @@ impl Io { // no longer be available to the next command, since we have // them buffered in memory rather than them being on the stdin // pipe. - let mut c = [0_u8]; - loop { - match (&*fh).read_exact(&mut c[..]).await { - Ok(()) => {} - Err(e) => { - if e.kind() == std::io::ErrorKind::UnexpectedEof { - break; - } - return Err(e.into()); - } - } - if c[0] == b'\n' { + let mut bytes = fh.bytes(); + while let Some(byte) = bytes.next().await { + let byte = byte?; + buf.push(byte); + if byte == b'\n' { break; } - buf.push(c[0]); } } } -- cgit v1.2.3-54-g00ecf