mirror of
https://github.com/nushell/nushell
synced 2025-01-14 06:04:09 +00:00
Load env pwd (#7963)
# Description Fixes #7940 avoid `load-env` to change PWD # User-Facing Changes `{"PWD": whatever} | load-env` now fails
This commit is contained in:
parent
ec4370069a
commit
aef88aa03e
2 changed files with 8 additions and 4 deletions
5
crates/nu-command/src/env/load_env.rs
vendored
5
crates/nu-command/src/env/load_env.rs
vendored
|
@ -47,10 +47,7 @@ impl Command for LoadEnv {
|
||||||
}
|
}
|
||||||
|
|
||||||
if env_var == "PWD" {
|
if env_var == "PWD" {
|
||||||
let cwd = current_dir(engine_state, stack)?;
|
return Err(ShellError::AutomaticEnvVarSetManually(env_var, call.head));
|
||||||
let rhs = rhs.as_string()?;
|
|
||||||
let rhs = nu_path::expand_path_with(rhs, cwd);
|
|
||||||
stack.add_env_var(env_var, Value::string(rhs.to_string_lossy(), call.head));
|
|
||||||
} else {
|
} else {
|
||||||
stack.add_env_var(env_var, rhs);
|
stack.add_env_var(env_var, rhs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,13 @@ fn load_env_file_pwd_env_var_fails() {
|
||||||
assert!(actual.err.contains("automatic_env_var_set_manually"));
|
assert!(actual.err.contains("automatic_env_var_set_manually"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn load_env_pwd_env_var_fails() {
|
||||||
|
let actual = nu!(cwd: ".", r#"load-env { PWD : 'foo' }"#);
|
||||||
|
|
||||||
|
assert!(actual.err.contains("automatic_env_var_set_manually"));
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: for some reason Nu is attempting to execute foo in `let-env FOO = foo`
|
// FIXME: for some reason Nu is attempting to execute foo in `let-env FOO = foo`
|
||||||
#[ignore]
|
#[ignore]
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue