Skip to content

Commit

Permalink
Revert "fix: make exec command decrement SHLVL correctly" (#14580)
Browse files Browse the repository at this point in the history
  • Loading branch information
fdncred authored Dec 14, 2024
1 parent cc0616b commit 05ee7ea
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
10 changes: 0 additions & 10 deletions crates/nu-command/src/system/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<i64>().unwrap_or(0))
.unwrap_or(0);
shlvl += 1;
engine_state.add_env_var("SHLVL".to_string(), Value::int(shlvl, Span::unknown()));
Expand Down

0 comments on commit 05ee7ea

Please sign in to comment.