Run ENV_CONVERSIONS whenever it's modified (#14591)

- this PR should close #14514

# Description
Makes updates to `$env.ENV_CONVERSIONS` take effect immediately.

# User-Facing Changes
No breaking change, `$env.ENV_CONVERSIONS` can be set and its effect
used in the same file.

# Tests + Formatting

- 🟢 toolkit fmt
- 🟢 toolkit clippy
- 🟢 toolkit test
- 🟢 toolkit test stdlib

# After Submitting
N/A
This commit is contained in:
Bahex
2024-12-25 16:37:24 +03:00
committed by GitHub
parent 45ff964cbd
commit 1b01598840
4 changed files with 118 additions and 65 deletions

View File

@ -14,7 +14,9 @@ use nu_protocol::{
};
use nu_utils::IgnoreCaseExt;
use crate::{eval::is_automatic_env_var, eval_block_with_early_return};
use crate::{
convert_env_vars, eval::is_automatic_env_var, eval_block_with_early_return, ENV_CONVERSIONS,
};
/// Evaluate the compiled representation of a [`Block`].
pub fn eval_ir_block<D: DebugContext>(
@ -384,10 +386,16 @@ fn eval_instruction<D: DebugContext>(
if !is_automatic_env_var(&key) {
let is_config = key == "config";
ctx.stack.add_env_var(key.into_owned(), value);
let update_conversions = key == ENV_CONVERSIONS;
ctx.stack.add_env_var(key.into_owned(), value.clone());
if is_config {
ctx.stack.update_config(ctx.engine_state)?;
}
if update_conversions {
convert_env_vars(ctx.stack, ctx.engine_state, &value)?;
}
Ok(Continue)
} else {
Err(ShellError::AutomaticEnvVarSetManually {