summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-01-18 03:31:43 -0500
committerJesse Luehrs <doy@tozt.net>2022-01-18 03:31:43 -0500
commit88cc6c1141eb9e279b73ce0229bf130885836f35 (patch)
treefa487dd604d9e8d39aff5d907fae5c26af7082bb /src
parent0e4742fc76bd6474358884f1929643483670cc54 (diff)
downloadnbsh-88cc6c1141eb9e279b73ce0229bf130885836f35.tar.gz
nbsh-88cc6c1141eb9e279b73ce0229bf130885836f35.zip
simplify
Diffstat (limited to 'src')
-rw-r--r--src/runner/builtins/command.rs18
1 files changed, 5 insertions, 13 deletions
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]);
}
}
}