Skip to content

Commit d7f4354

Browse files
authored
Replace dashes with underscores when using --evaluate-format shell (#3278)
1 parent 6d2173e commit d7f4354

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/justfile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl<'src> Justfile<'src> {
319319
if binding.export || module.settings.export {
320320
print!("export ");
321321
}
322-
print!("{}=\"", binding.name);
322+
print!("{}=\"", binding.name.lexeme().replace('-', "_"));
323323
for c in binding.value.chars() {
324324
if matches!(c, '!' | '"' | '$' | '\\' | '`') {
325325
print!("\\");

tests/evaluate.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,20 @@ fn format_shell_variables_are_exported_with_setting() {
312312
)
313313
.success();
314314
}
315+
316+
#[test]
317+
fn format_shell_dashes_in_variables_are_replaced_with_underscores() {
318+
Test::new()
319+
.args(["--evaluate", "--evaluate-format", "shell"])
320+
.justfile(
321+
"
322+
foo-bar := 'baz'
323+
",
324+
)
325+
.stdout(
326+
r#"
327+
foo_bar="baz"
328+
"#,
329+
)
330+
.success();
331+
}

0 commit comments

Comments
 (0)