aboutsummaryrefslogtreecommitdiffstats
path: root/src/run/mod.rs
diff options
context:
space:
mode:
authorJonas Maier <>2026-03-06 18:56:31 +0100
committerJonas Maier <>2026-03-06 18:56:31 +0100
commite01a65991b167d74f58f154a0002fa1740cfde66 (patch)
treec61b05ee6238811777dcef9d64ded00257c3de8c /src/run/mod.rs
parent2e55d27f565ec96c7238b35191ae5c65c2b6bc57 (diff)
downloadpish-e01a65991b167d74f58f154a0002fa1740cfde66.tar.gz
strip last newline
Diffstat (limited to 'src/run/mod.rs')
-rw-r--r--src/run/mod.rs12
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)
}
}