Skip to content

Windows PowerShell 5.1 环境下,bash 工具的 PS 包装层 (-Command "& { ... }") 解析器状态机存在BUG #1956

Description

@maliang668

Description

Windows PowerShell 5.1 环境下,bash 工具的 PS 包装层 (-Command "& { ... }") 解析器状态机存在致命缺陷。
command 参数字符串含 { } " 字符时(例如嵌套 JSON 或含 description 字段),PS 5.1 解析器立即报语法错误。更严重的是,该错误永久污染当前会话的 PS 解析器状态,后续所有 bash 调用无论格式正确与否均失败,必须重启 agent 会话才能恢复。

环境

  • OS: Windows 10+ (nt)
  • Shell: PowerShell 5.1
  • MiMoCode 版本: v0.1.9

复现步骤

  1. 在 Windows 上启动新 session
  2. 第一次 bash 调用使用带 description 字段的格式:
    {"command": "git status", "description": "Check status"}
    
  3. 后续所有 bash 调用(包括之前的正确格式)均返回 PS parse error

根本原因

工具内部将 JSON 参数字符串直接嵌入 PS 5.1 的 & { ... } 脚本块中执行:

powershell -NoProfile -Command "& { <command 字符串直接嵌入> }"

PS 5.1 的解析器是状态机,遇到 { " : 等字符在脚本块中无法正确处理,一旦报错则当前会话不可恢复。

Plugins

No response

MiMoCode version

v0.1.9

Steps to reproduce

  1. 在 Windows 上启动新 session
  2. 第一次 bash 调用使用带 description 字段的格式:
    {"command": "git status", "description": "Check status"}
    
  3. 后续所有 bash 调用(包括之前的正确格式)均返回 PS parse error

Screenshot and/or share link

No response

Operating System

Windows 10+ (nt)

Terminal

Shell: PowerShell 5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions