diff options
author | Leo K <crowlkats@toaxl.com> | 2021-08-04 21:47:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-04 21:47:43 +0200 |
commit | 2ac031d6fd3cb9b98ffb1801033d96675291f577 (patch) | |
tree | e5ad7c2de4d7aa1dae09e57e6e70917eb313c972 /runtime/ops/process.rs | |
parent | 1cd95dd8b5046484ea79b1849e420d1c085d1e5b (diff) |
feat(unstable): clean environmental variables for subprocess (#11571)
This commit adds "Deno.RunOptions.clearEnv" option, that allows
to clear environmental variables from parent process before spawning
a subprocess.
Diffstat (limited to 'runtime/ops/process.rs')
-rw-r--r-- | runtime/ops/process.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs index 679deff98..0f0cc6e2a 100644 --- a/runtime/ops/process.rs +++ b/runtime/ops/process.rs @@ -61,6 +61,7 @@ fn subprocess_stdio_map(s: &str) -> Result<std::process::Stdio, AnyError> { pub struct RunArgs { cmd: Vec<String>, cwd: Option<String>, + clear_env: bool, env: Vec<(String, String)>, stdin: String, stdout: String, @@ -113,6 +114,11 @@ fn op_run( c.arg(arg); }); cwd.map(|d| c.current_dir(d)); + + if run_args.clear_env { + super::check_unstable(state, "Deno.run.clearEnv"); + c.env_clear(); + } for (key, value) in &env { c.env(key, value); } |