forked from extern/nushell
Allow let-env to be dynamic (#940)
This commit is contained in:
parent
8204cc4f28
commit
f29dbeddd7
6
crates/nu-command/src/env/let_env.rs
vendored
6
crates/nu-command/src/env/let_env.rs
vendored
@ -1,4 +1,4 @@
|
|||||||
use nu_engine::{current_dir, eval_expression_with_input};
|
use nu_engine::{current_dir, eval_expression_with_input, CallExt};
|
||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||||
use nu_protocol::{Category, PipelineData, Signature, SyntaxShape, Value};
|
use nu_protocol::{Category, PipelineData, Signature, SyntaxShape, Value};
|
||||||
@ -33,9 +33,7 @@ impl Command for LetEnv {
|
|||||||
call: &Call,
|
call: &Call,
|
||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||||
let env_var = call.positional[0]
|
let env_var = call.req(engine_state, stack, 0)?;
|
||||||
.as_string()
|
|
||||||
.expect("internal error: missing variable");
|
|
||||||
|
|
||||||
let keyword_expr = call.positional[1]
|
let keyword_expr = call.positional[1]
|
||||||
.as_keyword()
|
.as_keyword()
|
||||||
|
@ -230,3 +230,8 @@ fn export_def_env() -> TestResult {
|
|||||||
"BAZ",
|
"BAZ",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn dynamic_let_env() -> TestResult {
|
||||||
|
run_test(r#"let x = "FOO"; let-env $x = "BAZ"; $env.FOO"#, "BAZ")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user