fix: 按平台选择 shell,修复 Windows 上 execute 工具 /bin/sh not found - #254
Open
zhaji2333 wants to merge 1 commit into
Open
fix: 按平台选择 shell,修复 Windows 上 execute 工具 /bin/sh not found#254zhaji2333 wants to merge 1 commit into
zhaji2333 wants to merge 1 commit into
Conversation
execute 流式 shell 硬编码 /bin/sh -c,Windows 平台直接报 exec: "/bin/sh": executable file not found。按 runtime.GOOS 选择: Windows 走 cmd /c,类 Unix 保持 /bin/sh -c 不变;同时 Windows 下跳过 sh 专用命令预处理(export、/dev/null 等),避免 cmd 执行失败。 为依赖 sh 语法断言的流式测试补充 Windows skip(修复前后在 Windows 均无法通过)。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #240
问题
internal/security/shell_execute_stream.go中 execute 流式 shell 硬编码/bin/sh -c,Windows 平台直接报:(issue #240 原始报错,修复前本机可稳定复现)
修复
newShellCommand:按runtime.GOOS选择 shell,Windows 走cmd /c,类 Unix 保持/bin/sh -c不变;prepareShellCommandForPlatform:Windows 下跳过 sh 专用命令预处理(export、</dev/null注入、后台段重定向等),避免 cmd 执行失败;类 Unix 行为与原先完全一致;shell_session_test.go的 skip 惯例一致)。验证
go build ./...全项目编译通过;go test ./internal/security/通过(Windows 本机实测);echo hello-from-cmd && ver,正常输出命令结果与 Windows 版本号。