diff options
| author | Jonas Maier <jonas@x77.dev> | 2026-03-14 22:12:42 +0100 |
|---|---|---|
| committer | Jonas Maier <jonas@x77.dev> | 2026-03-14 22:12:42 +0100 |
| commit | 3f7d80b746df37ffcb76076d84c15b7027042a89 (patch) | |
| tree | b0f5cc10b937c8f06a9e65458e01fd05e7d18878 /src/run/mod.rs | |
| parent | ad9572cc6e89634a4d029cc8d311bb51626c17c3 (diff) | |
| download | pish-3f7d80b746df37ffcb76076d84c15b7027042a89.tar.gz | |
proper blocks
Diffstat (limited to 'src/run/mod.rs')
| -rw-r--r-- | src/run/mod.rs | 27 |
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>, |
