forked from extern/nushell
Enable string interpolation for environment shorthand (#5463)
This commit is contained in:
parent
b0647f780d
commit
08e495ea67
@ -4287,13 +4287,16 @@ pub fn parse_expression(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
let rhs = if spans[pos].start + point < spans[pos].end {
|
let rhs = if spans[pos].start + point < spans[pos].end {
|
||||||
parse_string_strict(
|
let rhs_span = Span {
|
||||||
working_set,
|
start: spans[pos].start + point,
|
||||||
Span {
|
end: spans[pos].end,
|
||||||
start: spans[pos].start + point,
|
};
|
||||||
end: spans[pos].end,
|
|
||||||
},
|
if working_set.get_span_contents(rhs_span).starts_with(b"$") {
|
||||||
)
|
parse_dollar_expr(working_set, rhs_span, expand_aliases_denylist)
|
||||||
|
} else {
|
||||||
|
parse_string_strict(working_set, rhs_span)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
(
|
(
|
||||||
Expression {
|
Expression {
|
||||||
|
@ -22,6 +22,15 @@ fn env_shorthand_with_equals() {
|
|||||||
assert_eq!(actual.out, "my_module=info");
|
assert_eq!(actual.out, "my_module=info");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn env_shorthand_with_interpolation() {
|
||||||
|
let actual = nu!(cwd: ".", r#"
|
||||||
|
let num = 123
|
||||||
|
FOO=$"($num) bar" echo $env.FOO
|
||||||
|
"#);
|
||||||
|
assert_eq!(actual.out, "123 bar");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn env_shorthand_with_comma_equals() {
|
fn env_shorthand_with_comma_equals() {
|
||||||
let actual = nu!(cwd: ".", r#"
|
let actual = nu!(cwd: ".", r#"
|
||||||
|
Loading…
Reference in New Issue
Block a user