mirror of
https://github.com/nushell/nushell.git
synced 2025-05-09 12:34:26 +02:00
fix(cell-path): special case $env
This commit is contained in:
parent
e10538bd8d
commit
e48ad0d531
@ -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) {
|
||||
|
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user