From 05ee7ea9c78cb9ead9dbf380a1c3322d4cf226e5 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Fri, 13 Dec 2024 18:34:33 -0600 Subject: [PATCH] Revert "fix: make exec command decrement SHLVL correctly" (#14580) Reverts nushell/nushell#14570 --- crates/nu-command/src/system/exec.rs | 10 ---------- src/main.rs | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/crates/nu-command/src/system/exec.rs b/crates/nu-command/src/system/exec.rs index e9f49b86c1..8a2b24a113 100644 --- a/crates/nu-command/src/system/exec.rs +++ b/crates/nu-command/src/system/exec.rs @@ -61,16 +61,6 @@ On Windows based systems, Nushell will wait for the command to finish and then e let envs = env_to_strings(engine_state, stack)?; command.env_clear(); command.envs(envs); - // Decrement SHLVL as removing the current shell from the stack - // (only works in interactive mode, same as initialization) - if engine_state.is_interactive { - if let Some(shlvl) = engine_state.get_env_var("SHLVL") { - let shlvl = shlvl.as_int().unwrap_or(1) - 1; - command.env("SHLVL", shlvl.to_string()); - } else { - command.env("SHLVL", "0"); - } - } // Configure args. let args = crate::eval_arguments_from_call(engine_state, stack, call)?; diff --git a/src/main.rs b/src/main.rs index db55db3ff2..7d39aef02b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -325,7 +325,7 @@ fn main() -> Result<()> { if engine_state.is_interactive { let mut shlvl = engine_state .get_env_var("SHLVL") - .map(|x| x.as_int().unwrap_or(0)) + .map(|x| x.as_str().unwrap_or("0").parse::().unwrap_or(0)) .unwrap_or(0); shlvl += 1; engine_state.add_env_var("SHLVL".to_string(), Value::int(shlvl, Span::unknown()));