Cross-tool .claude/settings.local.json hooks with shell operators ( || , && ) break on Windows PowerShell
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Shell
- Sterne
- 11.2k
- Forks
- 1.9k
- Ø Merge
- 14 Std. 16 Min.
- Gemergte PRs (30 T.)
- 6
Beschreibung
Describe the bug
When a repository contains a Claude Code hook config ( .claude/settings.local.json or .claude/settings.json ) with a PreToolUse hook defined via a single cross-platform command string containing POSIX shell operators (e.g. ... || echo {} ), Copilot CLI fails to execute that hook correctly on Windows, which can block all subsequent tool calls gated by that hook.
Root cause hypothesis:
Claude Code executes these same hook commands via git-bash on Windows, so || / && work there. Copilot CLI's cross-tool compatibility layer, per the hooks reference, reads .claude/settings*.json files but runs the single command string as the native Windows powershell fallback rather than replicating Claude Code's git-bash execution context. This makes any Claude hook authored with POSIX-only shell syntax silently non-functional (and blocking) on Windows.
Affected version
No response
Steps to reproduce the behavior
- On Windows, in a repo, create .claude/settings.local.json with:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{ "type": "command", "command": ""C:\path\to\tool.exe" some-check || echo {}" }
]
}
]
}
} - Launch copilot in a native Windows PowerShell (5.1) terminal in that repo.
- Attempt any shell/Bash tool call.
Expected behavior
Expected behavior:
The hook executes successfully and either allows or blocks the tool call based on its actual logic, consistent with how the same config works under Claude Code.
Actual behavior:
The tool call is blocked. /env confirms the hook is loaded ("preToolUse: N hooks, source: repo settings"), but the underlying command fails silently, because || is invalid syntax in Windows PowerShell 5.1 — the shell that Copilot CLI uses to run the hook (per the docs, the command field is used as a fallback for both bash and powershell execution).
Additional context
Windows 11 Enterprise, PowerShell terminal (Windows PowerShell 5.1, not pwsh 7+)
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduzieren Sie das Problem mit .claude/settings.local.json oder .claude/settings.json, einem PreToolUse-Befehl unter Verwendung von || und Copilot CLI in Windows PowerShell 5.1. Prüfen Sie /env, um die Quelle des Hooks zu bestätigen, und beobachten Sie, ob der Befehl während eines Bash-Tool-Aufrufs fehlschlägt. Als abgeschlossen gilt die Aufgabe, wenn der Hook erfolgreich ausgeführt wird und den Tool-Aufruf entsprechend seinem Ergebnis zulässt oder blockiert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- powershell, shell
- Bereich
- cli
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100