Skip to content

Commit 8e02912

Browse files
Recognize .command files as shell scripts (#9345)
## Description Fixes #9213. On macOS, `.command` is the standard extension for double-clickable shell scripts (a `#!/usr/bin/env bash` file you can `chmod +x` and run from Finder). Opening one in Warp's editor today shows "Language support is unavailable for this file type" because `language_by_filename` in `crates/languages/src/lib.rs` doesn't include `command` next to the existing `sh | zsh | bash` shell extensions. ```diff - "sh" | "zsh" | "bash" => language_by_name("shell"), + "sh" | "zsh" | "bash" | "command" => language_by_name("shell"), ``` ## Testing - Added `command_extension_resolves_to_shell` in `crates/languages/src/lib_tests.rs` that calls `language_by_filename(Path::new("script.command"))` and asserts the returned language's `display_name` is `"Shell"` — fails on master, passes after the fix. - `cargo fmt -p languages -- --check` passes locally. - Couldn't run `cargo nextest run -p languages` locally because the Metal toolchain isn't installed (same situation as #9277), so relying on CI for the full clippy / nextest pass. ## Changelog Entries for Stable CHANGELOG-BUG-FIX: `.command` shell scripts now open with shell syntax highlighting in Warp's editor. Co-authored-by: anshul-garg27 <anshul-garg27@users.noreply.github.com>
1 parent 38f8d5b commit 8e02912

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

‎crates/languages/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ pub fn language_by_filename(path: &Path) -> Option<Arc<Language>> {
153153
"ts" | "cts" | "mts" => language_by_name("typescript"),
154154
"java" | "groovy" | "gvy" | "gy" | "gsh" => language_by_name("java"),
155155
"cpp" | "cxx" | "cc" | "h" | "hh" | "hpp" | "hxx" | "H" | "h++" => language_by_name("cpp"),
156-
"sh" | "zsh" | "bash" => language_by_name("shell"),
156+
"sh" | "zsh" | "bash" | "command" => language_by_name("shell"),
157157
"cs" => language_by_name("csharp"),
158158
"html" | "htm" => language_by_name("html"),
159159
"css" => language_by_name("css"),

‎crates/languages/src/lib_tests.rs‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ fn html_extensions_resolve_to_html() {
4141
}
4242
}
4343

44+
/// `.command` is the macOS convention for double-clickable shell scripts.
45+
/// Make sure `language_by_filename` recognizes it as shell so the editor
46+
/// renders syntax highlighting instead of the
47+
/// "Language support is unavailable for this file type" footer.
4448
#[test]
45-
fn cpp_header_extensions_resolve_to_cpp_language() {
46-
// Cover the common modern C++ header extensions (`.hpp`, `.hxx`),
47-
// the older uppercase `.H` convention, and the rarer `.h++` form.
48-
for filename in ["header.hpp", "header.hxx", "header.H", "header.h++"] {
49-
let language = language_by_filename(Path::new(filename))
50-
.unwrap_or_else(|| panic!("expected {filename} to resolve to C++"));
51-
52-
assert_eq!(language.display_name(), "C++");
53-
}
49+
fn command_extension_resolves_to_shell() {
50+
let language = language_by_filename(Path::new("script.command"))
51+
.expect("`.command` files should resolve to a language");
52+
assert_eq!(language.display_name(), "Shell");
5453
}

0 commit comments

Comments
 (0)