diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-01-17 18:06:14 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-01-17 18:06:14 -0500 |
commit | b95a6415d5c85fcbbc5dfc5983838530fdcff190 (patch) | |
tree | 7682b731a00180501ae4807eafe6a100ebeafc11 /src/runner | |
parent | 1d73e2c9cd196b6bbcda085e4db5ca25d615fb47 (diff) | |
download | nbsh-b95a6415d5c85fcbbc5dfc5983838530fdcff190.tar.gz nbsh-b95a6415d5c85fcbbc5dfc5983838530fdcff190.zip |
make eval async
Diffstat (limited to 'src/runner')
-rw-r--r-- | src/runner/mod.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/runner/mod.rs b/src/runner/mod.rs index 6d3710e..1633ba0 100644 --- a/src/runner/mod.rs +++ b/src/runner/mod.rs @@ -147,10 +147,13 @@ async fn run_commands( if stack.should_execute() { list.clone() .into_iter() - .map(|w| { - w.eval(env).map(IntoIterator::into_iter) + .map(|w| async { + w.eval(env) + .await + .map(IntoIterator::into_iter) }) - .collect::<Result<Vec<_>, _>>()? + .collect::<futures_util::stream::FuturesOrdered<_>>() + .collect::<Result<Vec<_>, _>>().await? .into_iter() .flatten() .collect() @@ -247,6 +250,7 @@ async fn run_pipeline( io.set_stderr(stderr); let pwd = env.pwd().to_path_buf(); + let pipeline = pipeline.eval(env).await?; let (children, pg) = spawn_children(pipeline, env, &io)?; let status = wait_children(children, pg, env, &io, shell_write).await; set_foreground_pg(nix::unistd::getpid())?; @@ -270,11 +274,10 @@ async fn write_event( } fn spawn_children<'a>( - pipeline: crate::parse::ast::Pipeline, + pipeline: crate::parse::Pipeline, env: &'a Env, io: &builtins::Io, ) -> anyhow::Result<(Vec<Child<'a>>, Option<nix::unistd::Pid>)> { - let pipeline = pipeline.eval(env)?; let mut cmds: Vec<_> = pipeline .into_exes() .map(|exe| Command::new(exe, io.clone())) |