github / github/copilot-cli

Cross-tool  .claude/settings.local.json  hooks with shell operators ( || ,  && ) break on Windows PowerShell

Aperta
#4,399 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
area:configuration area:platform-windows
Lingua principale
Shell
Stelle
11.2k
Fork
1.9k
Merge medio
14h 16m
PR unite (30g)
6

Descrizione

### 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

1. 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 {}" }
]
}
]
}
}
2. Launch  copilot  in a native Windows PowerShell (5.1) terminal in that repo.
3. 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+)

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Riproduci il problema con .claude/settings.local.json o .claude/settings.json, un comando PreToolUse che utilizzi || e Copilot CLI in Windows PowerShell 5.1. Controlla /env per confermare l’origine dell’hook e osserva se il comando non riesce durante una chiamata allo strumento Bash. Il lavoro è completato quando l’hook viene eseguito correttamente e consente o blocca la chiamata allo strumento in base al risultato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
powershell, shell
Ambito
cli
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.