Cross-tool .claude/settings.local.json hooks with shell operators ( || , && ) break on Windows PowerShell
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Shell
- Star
- 11.2k
- Fork
- 1.9k
- Merge trung bình
- 14 giờ 16 phút
- Pull request đã merge (30 ngày)
- 6
Mô tả
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+)
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện sự cố với .claude/settings.local.json hoặc .claude/settings.json, một lệnh PreToolUse sử dụng || và Copilot CLI trong Windows PowerShell 5.1. Kiểm tra /env để xác nhận nguồn của hook và quan sát xem lệnh có bị lỗi trong khi gọi công cụ Bash hay không. Hoàn tất khi hook thực thi thành công và cho phép hoặc chặn lệnh gọi công cụ theo kết quả của nó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- powershell, shell
- Lĩnh vực
- cli
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100