MCPcopy Create free account
hub / github.com/Louisym/MiniCC / prepare_tokio_command

Function prepare_tokio_command

rust/crates/runtime/src/bash.rs:209–234  ·  view source on GitHub ↗
(
    command: &str,
    cwd: &std::path::Path,
    sandbox_status: &SandboxStatus,
    create_dirs: bool,
)

Source from the content-addressed store, hash-verified

207}
208
209fn prepare_tokio_command(
210 command: &str,
211 cwd: &std::path::Path,
212 sandbox_status: &SandboxStatus,
213 create_dirs: bool,
214) -> TokioCommand {
215 if create_dirs {
216 prepare_sandbox_dirs(cwd);
217 }
218
219 if let Some(launcher) = build_linux_sandbox_command(command, cwd, sandbox_status) {
220 let mut prepared = TokioCommand::new(launcher.program);
221 prepared.args(launcher.args);
222 prepared.current_dir(cwd);
223 prepared.envs(launcher.env);
224 return prepared;
225 }
226
227 let mut prepared = TokioCommand::new("sh");
228 prepared.arg("-lc").arg(command).current_dir(cwd);
229 if sandbox_status.filesystem_active {
230 prepared.env("HOME", cwd.join(".sandbox-home"));
231 prepared.env("TMPDIR", cwd.join(".sandbox-tmp"));
232 }
233 prepared
234}
235
236fn prepare_sandbox_dirs(cwd: &std::path::Path) {
237 let _ = std::fs::create_dir_all(cwd.join(".sandbox-home"));

Callers 1

execute_bash_asyncFunction · 0.85

Calls 3

envMethod · 0.80
prepare_sandbox_dirsFunction · 0.70

Tested by

no test coverage detected