diff --git a/src/shebang.rs b/src/shebang.rs index 1b7852a36f..00cfe26e83 100644 --- a/src/shebang.rs +++ b/src/shebang.rs @@ -47,7 +47,7 @@ impl<'line> Shebang<'line> { } pub(crate) fn include_shebang_line(&self) -> bool { - !matches!(self.interpreter_filename(), "cmd" | "cmd.exe") + !cfg!(windows) && !matches!(self.interpreter_filename(), "cmd" | "cmd.exe") } } @@ -201,7 +201,14 @@ mod tests { } #[test] - fn include_shebang_line_other() { + #[cfg(not(windows))] + fn include_shebang_line_other_not_windows() { assert!(Shebang::new("#!foo -c").unwrap().include_shebang_line()); } + + #[test] + #[cfg(windows)] + fn include_shebang_line_other_windows() { + assert!(!Shebang::new("#!foo -c").unwrap().include_shebang_line()); + } } diff --git a/tests/misc.rs b/tests/misc.rs index 1c5ef20437..4a903bca39 100644 --- a/tests/misc.rs +++ b/tests/misc.rs @@ -1081,6 +1081,7 @@ test! { stderr: "#!/bin/sh\necho hello\n", } +#[cfg(not(windows))] test! { name: shebang_line_numbers, justfile: r#" @@ -1100,6 +1101,36 @@ test! { #!/usr/bin/env cat + a + + b + + + c + ", +} + +#[cfg(windows)] +test! { + name: shebang_line_numbers, + justfile: r#" + quiet: + #!/usr/bin/env cat + + a + + b + + + c + + + "#, + stdout: " + + + + a b diff --git a/tests/tempdir.rs b/tests/tempdir.rs index 843048be27..72e5021296 100644 --- a/tests/tempdir.rs +++ b/tests/tempdir.rs @@ -24,13 +24,21 @@ fn test_tempdir_is_set() { } }) .current_dir("foo") - .stdout( + .stdout(if cfg!(windows) { + " + + + + + cat just*/foo + " + } else { " #!/usr/bin/env bash cat just*/foo - ", - ) + " + }) .run(); }