Skip to content

Commit 13e1d7c

Browse files
authored
fix(non-interactive-env): use detectShellType() instead of hardcoded 'unix' (#1459)
The shellType was hardcoded to 'unix' which breaks on native Windows shells (cmd.exe, PowerShell) when running without Git Bash or WSL. This change uses the existing detectShellType() function to dynamically determine the correct shell type, enabling proper env var syntax for all supported shell environments.
1 parent 5361cd0 commit 13e1d7c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/hooks/non-interactive-env/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { PluginInput } from "@opencode-ai/plugin"
2-
import type { ShellType } from "../../shared"
32
import { HOOK_NAME, NON_INTERACTIVE_ENV, SHELL_COMMAND_PATTERNS } from "./constants"
4-
import { log, buildEnvPrefix } from "../../shared"
3+
import { log, buildEnvPrefix, detectShellType } from "../../shared"
54

65
export * from "./constants"
76
export * from "./detector"
@@ -53,10 +52,10 @@ export function createNonInteractiveEnvHook(_ctx: PluginInput) {
5352
// The env vars (GIT_EDITOR=:, EDITOR=:, etc.) must ALWAYS be injected
5453
// for git commands to prevent interactive prompts.
5554

56-
// The bash tool always runs in a Unix-like shell (bash/sh), even on Windows
57-
// (via Git Bash, WSL, etc.), so we always use unix export syntax.
58-
// This fixes GitHub issues #983 and #889.
59-
const shellType: ShellType = "unix"
55+
// Detect the shell type dynamically to support native Windows shells
56+
// (cmd.exe, PowerShell) in addition to Unix-like shells (bash, zsh).
57+
// Fixes Windows compatibility issues when running without Git Bash/WSL.
58+
const shellType = detectShellType()
6059
const envPrefix = buildEnvPrefix(NON_INTERACTIVE_ENV, shellType)
6160
output.args.command = `${envPrefix} ${command}`
6261

0 commit comments

Comments
 (0)