github / github/copilot-cli

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

Ouverte
#4,399 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

area:configuration area:platform-windows
Langage dominant
Shell
Étoiles
11.2k
Forks
1.9k
Merge moyen
14 h 16 min
PR mergées (30 j)
6

Description

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+)

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Reproduisez le problème avec .claude/settings.local.json ou .claude/settings.json, une commande PreToolUse utilisant || et Copilot CLI dans Windows PowerShell 5.1. Vérifiez /env pour confirmer la source du hook et observez si la commande échoue pendant un appel à l’outil Bash. Le travail est terminé lorsque le hook s’exécute correctement et autorise ou bloque l’appel à l’outil selon son résultat.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
powershell, shell
Domaine
cli
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.