github / github/copilot-cli

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

オープン
#4,399 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

area:configuration area:platform-windows
主要言語
Shell
スター
11.2k
フォーク
1.9k
平均マージ
14時間 16分
マージ済み PR(30日)
6

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

.claude/settings.local.json または .claude/settings.json、|| を使用する PreToolUse コマンド、および Windows PowerShell 5.1 の Copilot CLI で問題を再現します。/env を確認して hook のソースを確定し、Bash ツールの呼び出し中にコマンドが失敗するかを確認します。hook が正常に実行され、その結果に応じてツール呼び出しを許可またはブロックすれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
powershell, shell
領域
cli
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。