diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-01-17 01:33:04 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-01-17 01:33:04 -0500 |
commit | de7236e3ac7596dfdcd4b705861189ee9af9942c (patch) | |
tree | 3191b8695a00fcb66c20717ef576935aab693458 /src/runner/builtins/command.rs | |
parent | 9b1595b795121d233cd0cf32537661839e318914 (diff) | |
download | nbsh-de7236e3ac7596dfdcd4b705861189ee9af9942c.tar.gz nbsh-de7236e3ac7596dfdcd4b705861189ee9af9942c.zip |
fix reading empty lines
Diffstat (limited to 'src/runner/builtins/command.rs')
-rw-r--r-- | src/runner/builtins/command.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/runner/builtins/command.rs b/src/runner/builtins/command.rs index 7d84c8f..a2ba35d 100644 --- a/src/runner/builtins/command.rs +++ b/src/runner/builtins/command.rs @@ -185,17 +185,18 @@ impl Io { } } - pub async fn read_line_stdin(&self) -> anyhow::Result<String> { + pub async fn read_line_stdin(&self) -> anyhow::Result<(String, bool)> { let mut buf = String::new(); if let Some(fh) = self.stdin() { if let File::In(fh) = &mut *fh.lock_arc().await { fh.read_line(&mut buf).await?; } } + let done = buf.is_empty(); if buf.ends_with('\n') { buf.truncate(buf.len() - 1); } - Ok(buf) + Ok((buf, done)) } pub async fn write_stdout(&self, buf: &[u8]) -> anyhow::Result<()> { |