fix(commands): route bash scripts using shell syntax - #136
Closed
wuchulonly wants to merge 1 commit into
Closed
wuchulonly wants to merge 1 commit into
wuchulonly wants to merge 1 commit into
Conversation
M09Ic
force-pushed
the
fix/bash-shell-syntax-routing
branch
from
September 21, 2026 10:30
35e651f to
e7c1634
Compare
4 tasks
Contributor
|
Superseded by #146, which ports this parser onto the current terminal tool and is merged. Closing so the two fixes are not applied twice. |
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.
当输入
curl URL -o file.json; wc -c file.json时,原有分发逻辑按空白分词,将file.json;保留为一个参数,随后把整段脚本交给内置curl。结果是后续命令被当作 curl 的参数,wc没有执行。同一路径还会丢失引号内的空参数,并改写多行字符串和 heredoc 的内容。本次改动复用已有的
mvdan.cc/sh/v3依赖,先解析原始脚本的 Shell 语法,再决定执行方式:ProcessContainment钩子接入进程监督。EnableShellCommands,避免把后续命令误当成参数。Registry.Run将已经解析好的参数数组作为普通数据处理,不再根据参数中的分号、管道符等字符猜测 Shell 语法。已通过的验证:
go test -race -count=1 ./pkg/commands ./core/commandline ./pkg/exts/terminal ./core/extension ./core/registrygo vet ./pkg/commands ./core/commandline ./pkg/exts/terminalgo mod tidy -diffgit diff --check新增回归测试覆盖连写操作符、条件短路、换行、重定向、展开、引号与转义、空参数、heredoc、监督器接管和取消后的清理。使用本地模拟的
curl验证“下载文件后统计字节数”的原始场景,无需访问网络。现有两个方向的内置命令与 Shell 管道测试也保持通过。