aboutsummaryrefslogtreecommitdiffstats
path: root/src/run/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/run/mod.rs')
-rw-r--r--src/run/mod.rs27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/run/mod.rs b/src/run/mod.rs
index 751f557..5605639 100644
--- a/src/run/mod.rs
+++ b/src/run/mod.rs
@@ -213,14 +213,7 @@ impl Executor {
CommandKind::Fun(body) => {
let mut this = self.clone();
this.args = Some(args);
-
- let handle = wait::spawn(move || {
- let body = body.expand(&mut this)?;
- let cmd = this.execute(body, stdin, stdout);
- this.exec_loop(cmd, &mut [])
- });
-
- SpawnedCmd::Fun(handle)
+ this.execute_block(body, stdin, stdout)
}
CommandKind::Path(path) => {
let mut command = Command::new(&path);
@@ -241,6 +234,24 @@ impl Executor {
}
}
+ fn execute_block(
+ &mut self,
+ block: parse::Block,
+ stdin: InputReader,
+ stdout: OutputWriter,
+ ) -> SpawnedCmd {
+ let mut this = self.clone();
+ let handle = wait::spawn(move || -> Result<(), ExecError> {
+ for cmd in block.commands {
+ let cmd = cmd.expand(&mut this)?;
+ this.execute(cmd, stdin.try_clone()?, stdout.try_clone()?)
+ .join()?;
+ }
+ Ok(())
+ });
+ SpawnedCmd::Fun(handle)
+ }
+
fn execute_pipeline(
&mut self,
pipes: parse::Pipes<parse::PostExpansion>,