diff options
| author | Jonas Maier <> | 2026-03-06 18:56:31 +0100 |
|---|---|---|
| committer | Jonas Maier <> | 2026-03-06 18:56:31 +0100 |
| commit | e01a65991b167d74f58f154a0002fa1740cfde66 (patch) | |
| tree | c61b05ee6238811777dcef9d64ded00257c3de8c | |
| parent | 2e55d27f565ec96c7238b35191ae5c65c2b6bc57 (diff) | |
| download | pish-e01a65991b167d74f58f154a0002fa1740cfde66.tar.gz | |
strip last newline
| -rw-r--r-- | src/run/mod.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/run/mod.rs b/src/run/mod.rs index b45fac8..ba37061 100644 --- a/src/run/mod.rs +++ b/src/run/mod.rs @@ -183,13 +183,8 @@ impl<'a> Executor<'a> { if let Some(cap) = capture { if last_is_command { - let child = children - .into_iter() - .last() - .unwrap(); - let out = child - .wait_with_output() - .unwrap(); + let child = children.into_iter().last().unwrap(); + let out = child.wait_with_output().unwrap(); *cap = out.stdout; } else { *cap = last_output.into_inner(); @@ -218,6 +213,9 @@ impl<'a> parse::Expander for Executor<'a> { fn expand_cmd(&mut self, ast: Ast<parse::PostExpansion>) -> Result<BString, Self::Error> { let mut out = Vec::new(); self.execute(ast, Some(&mut out))?; + if out.last() == Some(&b'\n') { + out.pop(); + } Ok(out) } } |
