diff --git a/crates/nu-engine/src/eval.rs b/crates/nu-engine/src/eval.rs index 9b74626a01..2ca15c1922 100644 --- a/crates/nu-engine/src/eval.rs +++ b/crates/nu-engine/src/eval.rs @@ -592,8 +592,11 @@ impl Eval for EvalRuntime { // Retrieve the updated environment value. lhs.upsert_data_at_cell_path(&cell_path.tail, rhs)?; - let value = - lhs.follow_cell_path(&[cell_path.tail[0].clone()], true)?; + let value = lhs.follow_cell_path(&[{ + let mut pm = cell_path.tail[0].clone(); + pm.make_insensitive(); + pm + }])?; // Reject attempts to set automatic environment variables. if is_automatic_env_var(&original_key) { diff --git a/crates/nu-protocol/src/eval_base.rs b/crates/nu-protocol/src/eval_base.rs index 65c9b5f82b..56cf2f4b8f 100644 --- a/crates/nu-protocol/src/eval_base.rs +++ b/crates/nu-protocol/src/eval_base.rs @@ -43,8 +43,16 @@ pub trait Eval { // Cell paths are usually case-sensitive, but we give $env // special treatment. - let insensitive = cell_path.head.expr == Expr::Var(ENV_VARIABLE_ID); - value.follow_cell_path(&cell_path.tail, insensitive).map(Cow::into_owned) + let tail = if cell_path.head.expr == Expr::Var(ENV_VARIABLE_ID) { + let mut tail = cell_path.tail.clone(); + if let Some(pm) = tail.first_mut() { + pm.make_insensitive(); + } + Cow::Owned(tail) + } else { + Cow::Borrowed(&cell_path.tail) + }; + value.follow_cell_path(&tail).map(Cow::into_owned) } Expr::DateTime(dt) => Ok(Value::date(*dt, expr_span)), Expr::List(list) => {