From 13e1d7cbd7494419f2afe31b5828a437d09434fe Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 4 Feb 2026 10:52:46 +0900 Subject: [PATCH] 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. --- src/hooks/non-interactive-env/index.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/hooks/non-interactive-env/index.ts b/src/hooks/non-interactive-env/index.ts index c85c7efd..19316082 100644 --- a/src/hooks/non-interactive-env/index.ts +++ b/src/hooks/non-interactive-env/index.ts @@ -1,7 +1,6 @@ import type { PluginInput } from "@opencode-ai/plugin" -import type { ShellType } from "../../shared" import { HOOK_NAME, NON_INTERACTIVE_ENV, SHELL_COMMAND_PATTERNS } from "./constants" -import { log, buildEnvPrefix } from "../../shared" +import { log, buildEnvPrefix, detectShellType } from "../../shared" export * from "./constants" export * from "./detector" @@ -53,10 +52,10 @@ export function createNonInteractiveEnvHook(_ctx: PluginInput) { // The env vars (GIT_EDITOR=:, EDITOR=:, etc.) must ALWAYS be injected // for git commands to prevent interactive prompts. - // The bash tool always runs in a Unix-like shell (bash/sh), even on Windows - // (via Git Bash, WSL, etc.), so we always use unix export syntax. - // This fixes GitHub issues #983 and #889. - const shellType: ShellType = "unix" + // Detect the shell type dynamically to support native Windows shells + // (cmd.exe, PowerShell) in addition to Unix-like shells (bash, zsh). + // Fixes Windows compatibility issues when running without Git Bash/WSL. + const shellType = detectShellType() const envPrefix = buildEnvPrefix(NON_INTERACTIVE_ENV, shellType) output.args.command = `${envPrefix} ${command}`