forked from extern/nushell
parent
b650d1ef79
commit
75556f6c5f
17
crates/nu-command/src/env/let_env.rs
vendored
17
crates/nu-command/src/env/let_env.rs
vendored
@ -1,4 +1,4 @@
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user