Skip to content

Commit 6753987

Browse files
committed
feat: enable fish and nu shell support in Bash tool
Remove the fish/nu blacklist so commands execute in the user's actual shell. Previously, fish and nu were blacklisted and commands would fall back to zsh/bash, causing the tool description to incorrectly report the shell being used. Changes: - Remove fish/nu blacklist from bash.ts shell detection - Remove unused BLACKLIST constant and Shell.acceptable() from shell.ts - Add fish shell test case to bash.test.ts Resolves anomalyco#4866
1 parent 91fc9cd commit 6753987

3 files changed

Lines changed: 8 additions & 18 deletions

File tree

‎packages/opencode/src/shell/shell.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export namespace Shell {
3333
}
3434
}
3535
}
36-
const BLACKLIST = new Set(["fish", "nu"])
3736

3837
function fallback() {
3938
if (process.platform === "win32") {
@@ -58,10 +57,4 @@ export namespace Shell {
5857
if (s) return s
5958
return fallback()
6059
})
61-
62-
export const acceptable = lazy(() => {
63-
const s = process.env.SHELL
64-
if (s && !BLACKLIST.has(process.platform === "win32" ? path.win32.basename(s) : path.basename(s))) return s
65-
return fallback()
66-
})
6760
}

‎packages/opencode/src/tool/bash.ts‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,18 @@ const parser = lazy(async () => {
5555
export const BashTool = Tool.define("bash", async () => {
5656
const shell = (() => {
5757
const s = process.env.SHELL
58-
if (s) {
59-
const basename = path.basename(s)
60-
if (!new Set(["fish", "nu"]).has(basename)) {
61-
return s
62-
}
63-
}
58+
if (s) return s
6459

6560
if (process.platform === "darwin") {
6661
return "/bin/zsh"
6762
}
6863

6964
if (process.platform === "win32") {
70-
// Let Bun / Node pick COMSPEC (usually cmd.exe)
71-
// or explicitly:
7265
return process.env.COMSPEC || true
7366
}
7467

7568
const bash = Bun.which("bash")
76-
if (bash) {
77-
return bash
78-
}
69+
if (bash) return bash
7970

8071
return true
8172
})()

‎packages/opencode/test/tool/bash.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ describe("tool.bash", () => {
126126
const bashKsh = await BashTool.init()
127127
expect(bashKsh.description).toContain("ksh command")
128128
expect(bashKsh.description).toContain("ksh commands")
129+
130+
// Mock fish shell environment (fish is now supported, not blacklisted)
131+
process.env.SHELL = "/usr/bin/fish"
132+
const bashFish = await BashTool.init()
133+
expect(bashFish.description).toContain("fish command")
134+
expect(bashFish.description).toContain("fish commands")
129135
} finally {
130136
// Restore original shell
131137
if (originalShell) {

0 commit comments

Comments
 (0)