#254

fix: 按平台选择 shell,修复 Windows 上 execute 工具 /bin/sh not found

Openzhaji2333wants to merge intofrom

Fixes #240

问题

internal/security/shell_execute_stream.go 中 execute 流式 shell 硬编码 /bin/sh -c,Windows 平台直接报:

exec: "/bin/sh": executable file not found in %PATH%

(issue #240 原始报错,修复前本机可稳定复现)

修复

  • 新增 newShellCommand:按 runtime.GOOS 选择 shell,Windows 走 cmd /c,类 Unix 保持 /bin/sh -c 不变;
  • 新增 prepareShellCommandForPlatform:Windows 下跳过 sh 专用命令预处理(export、</dev/null 注入、后台段重定向等),避免 cmd 执行失败;类 Unix 行为与原先完全一致;
  • 为依赖 sh 语法断言的流式测试补充 Windows skip(这些用例在修复前后于 Windows 均无法通过,与现有 shell_session_test.go 的 skip 惯例一致)。

验证

  • go build ./... 全项目编译通过;
  • go test ./internal/security/ 通过(Windows 本机实测);
  • 修复后通过 execute 工具在 Windows 真实执行 echo hello-from-cmd && ver,正常输出命令结果与 Windows 版本号。