Add shebang support for 'cmd.exe' (#828)
This commit is contained in:
parent
b26cb891b9
commit
7be66f890f
@ -127,8 +127,9 @@ impl<'src, D> Recipe<'src, D> {
|
||||
io_error: error,
|
||||
})?;
|
||||
let mut path = tmp.path().to_path_buf();
|
||||
let suffix = if interpreter.ends_with("powershell") || interpreter.ends_with("powershell.exe")
|
||||
{
|
||||
let suffix = if interpreter.ends_with("cmd") || interpreter.ends_with("cmd.exe") {
|
||||
".bat"
|
||||
} else if interpreter.ends_with("powershell") || interpreter.ends_with("powershell.exe") {
|
||||
".ps1"
|
||||
} else {
|
||||
""
|
||||
@ -141,7 +142,11 @@ impl<'src, D> Recipe<'src, D> {
|
||||
})?;
|
||||
let mut text = String::new();
|
||||
// add the shebang
|
||||
text += &evaluated_lines[0];
|
||||
if interpreter.ends_with("cmd") || interpreter.ends_with("cmd.exe") {
|
||||
text += "\n";
|
||||
} else {
|
||||
text += &evaluated_lines[0];
|
||||
}
|
||||
text += "\n";
|
||||
// add blank lines so that lines in the generated script have the same line
|
||||
// number as the corresponding lines in the justfile
|
||||
|
@ -19,3 +19,25 @@ default:
|
||||
"#,
|
||||
stdout: "Hello-World\n",
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
test! {
|
||||
name: cmd,
|
||||
justfile: r#"
|
||||
default:
|
||||
#!cmd /c
|
||||
@echo Hello-World
|
||||
"#,
|
||||
stdout: "Hello-World\r\n",
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
test! {
|
||||
name: cmd_exe,
|
||||
justfile: r#"
|
||||
default:
|
||||
#!cmd.exe /c
|
||||
@echo Hello-World
|
||||
"#,
|
||||
stdout: "Hello-World\r\n",
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user