diff options
| -rw-r--r-- | src/util/language.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/util/language.rs b/src/util/language.rs index 8819a1e..8da45b8 100644 --- a/src/util/language.rs +++ b/src/util/language.rs @@ -27,7 +27,7 @@ fn detect_from_shebang(contents: &str) -> Option<&'static str> { if first_line.contains("python") { return Some("python"); } - if first_line.contains("bash") { + if first_line.contains("bash") || first_line.contains("/sh") || first_line.contains(" sh") { return Some("bash"); } } @@ -51,4 +51,16 @@ mod tests { let contents = "#!/usr/bin/python3\nprint('hi')"; assert_eq!(detect_language(Path::new("file"), contents), "python"); } + + #[test] + fn sh_shebang_maps_to_bash_for_llm() { + let contents = "#!/bin/sh\necho hi"; + assert_eq!(detect_language(Path::new("file"), contents), "bash"); + } + + #[test] + fn env_shebang_is_detected() { + let contents = "#!/usr/bin/env sh\necho hi"; + assert_eq!(detect_language(Path::new("file"), contents), "bash"); + } } |
