Revert "fix: make exec command decrement SHLVL correctly" (#14580)

Reverts nushell/nushell#14570
This commit is contained in:
Darren Schroeder 2024-12-13 18:34:33 -06:00 committed by GitHub
parent cc0616b753
commit 05ee7ea9c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 11 deletions

View file

@ -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)?;

View file

@ -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()));