From 3f7d80b746df37ffcb76076d84c15b7027042a89 Mon Sep 17 00:00:00 2001 From: Jonas Maier Date: Sat, 14 Mar 2026 22:12:42 +0100 Subject: proper blocks --- src/run/mod.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/run/mod.rs') 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, -- cgit v1.2.3