fix(#7097): let-env should not be able to set PWD
-use nu_engine::{current_dir, eval_expression_with_input, CallExt};
+use nu_engine::{eval_expression_with_input, CallExt};
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
@@ -49,24 +49,11 @@ impl Command for LetEnv {
.0
.into_value(call.head);
- if env_var.item == "FILE_PWD" {
+ if env_var.item == "FILE_PWD" || env_var.item == "PWD" {
return Err(ShellError::AutomaticEnvVarSetManually(
env_var.item,
env_var.span,
));
- }
-
- if env_var.item == "PWD" {
- let cwd = current_dir(engine_state, stack)?;
- let rhs = rhs.as_string()?;
- let rhs = nu_path::expand_path_with(rhs, cwd);
- stack.add_env_var(
- env_var.item,
- Value::String {
- val: rhs.to_string_lossy().to_string(),
- span: call.head,
- },
- );
} else {
stack.add_env_var(env_var.item, rhs);
}
