From c8f54476c9249b8ccdc41299d5b1cd786bb53187 Mon Sep 17 00:00:00 2001 From: Jelle Besseling Date: Thu, 20 Apr 2023 12:10:46 +0200 Subject: [PATCH] Set env in exec command (#8917) # Description Previously variables with `let-env` were not available after doing an `exec` command. This PR fixes that # User-Facing Changes Can now use environment variables set with nushell after `exec` # Tests + Formatting No tests made but formatting has been checked # After Submitting Co-authored-by: Jelle Besseling --- crates/nu-command/src/system/exec.rs | 1 + crates/nu-command/src/system/run_external.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/nu-command/src/system/exec.rs b/crates/nu-command/src/system/exec.rs index acf845f8f4..e988d18960 100644 --- a/crates/nu-command/src/system/exec.rs +++ b/crates/nu-command/src/system/exec.rs @@ -81,6 +81,7 @@ fn exec( let cwd = current_dir(engine_state, stack)?; let mut command = external_command.spawn_simple_command(&cwd.to_string_lossy())?; command.current_dir(cwd); + command.envs(&external_command.env_vars); let err = command.exec(); // this replaces our process, should not return diff --git a/crates/nu-command/src/system/run_external.rs b/crates/nu-command/src/system/run_external.rs index 68c4299667..1de0513884 100644 --- a/crates/nu-command/src/system/run_external.rs +++ b/crates/nu-command/src/system/run_external.rs @@ -548,7 +548,7 @@ impl ExternalCommand { } } - fn create_process( + pub fn create_process( &self, input: &PipelineData, use_cmd: bool,