conch_runtime_pshaw/spawn/
subshell.rs1use crate::env::{ReportErrorEnvironment, SubEnvironment};
2use crate::{ExitStatus, Spawn, EXIT_ERROR};
3use std::error::Error;
4use std::future::Future;
5
6pub fn subshell<S, E>(spawn: S, env: &E) -> impl Future<Output = ExitStatus>
11where
12 S: Spawn<E>,
13 S::Error: 'static + Send + Sync + Error,
14 E: ReportErrorEnvironment + SubEnvironment,
15{
16 subshell_with_env(spawn, env.sub_env())
17}
18
19pub(crate) async fn subshell_with_env<S, E>(spawn: S, mut env: E) -> ExitStatus
20where
21 S: Spawn<E>,
22 S::Error: 'static + Send + Sync + Error,
23 E: ReportErrorEnvironment,
24{
25 match spawn.spawn(&mut env).await {
26 Ok(future) => future.await,
27 Err(e) => {
28 env.report_error(&e).await;
29 EXIT_ERROR
30 }
31 }
32}