fix(claude-hook): use forward slashes in Windows managed hook command path (#1329)

Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Leynier Gutiérrez González
2026-05-01 18:50:22 -07:00
committed by GitHub
co-authored by Amp
parent 0e06d2e9b5
commit 6faf406511
+9 -1
View File
@@ -48,7 +48,15 @@ function getManagedScriptPath(): string {
}
function getManagedCommand(scriptPath: string): string {
return process.platform === 'win32' ? scriptPath : `/bin/sh "${scriptPath}"`
// Why: on Windows, Claude Code runs hooks through Git Bash (`/usr/bin/bash`).
// A path with single backslashes (e.g. `C:\Users\…\claude-hook.cmd`) is
// interpreted by bash as a string with escape sequences, so `\U`, `\A`, etc.
// collapse and the launcher fails with `command not found`. Emit forward
// slashes — Windows accepts them in path arguments and bash leaves them
// intact, so the same JSON value works through every shell layer.
return process.platform === 'win32'
? scriptPath.replaceAll('\\', '/')
: `/bin/sh "${scriptPath}"`
}
function getManagedScript(): string {