Pull Request已成功合入, 合并人@CANN-robot
(感谢 jiangyixuan2 的贡献)变更摘要
本 PR 修复了旧版 bash 执行 init.sh 时因 heredoc 写法不规范导致的解析报错(Issue #608),并为同类问题补齐版本无关的看护测试。根因是 cuda2ascend 与 ops-direct-invoke 两个插件的 init.sh 中,命令替换的闭合 ) 与 heredoc 起始符写在同一行($( ... << 'TRAE_AGENT_PY' 2>/dev/null)),新版 bash(5.2+)仅警告而旧版 bash 会在解析期报 syntax error 并中断安装。修复方式是参照 POSIX 规范将 ) 移到 heredoc 终止符 TRAE_AGENT_PY 之后,逻辑零变化。
主要改动
- 修复
init.shheredoc 语法:在plugins-community/cuda2ascend/init.sh与plugins-official/ops-direct-invoke/init.sh中,将agent_count=$( ... << 'TRAE_AGENT_PY' 2>/dev/null)的闭合)移至 heredoc 终止符之后独立成行,消除旧版 bash 的解析期语法错误(行为无变化)。 - 新增解析诊断负向断言函数:
tests/behavior/install/test-init-behavior.sh新增assert_no_shell_warnings,对输出用grep -E "warning: (command substitution|here-document)|syntax error"检测 bash 解析诊断,命中即计入失败。 - 行为测试接入断言:在
test-init-behavior.sh的 18 个真实执行init.sh的场景(含 project/global 与 opencode、claude、trae、codearts、cursor、copilot 等参数组合)中调用assert_no_shell_warnings,要求输出不得包含 bash 解析诊断。 - 单测新增语法门禁:
tests/unit/install/test-init-install.sh新增 Check 5,遍历所有插件目录对每个init.sh及example/init.sh执行bash -n,要求 stderr 为空,从而在任何 bash 版本下拦截未闭合 heredoc 类问题。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/cannbot-skills | ✅ 金炯, hanrui22 (2/2) | ✅ 金炯, hanrui22 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
jiangyixuan2, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


流水线任务触发成功
任务链接 [56fcd86cc2cf4f569ace0d40601fc2cb][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| Check_Pr | ✅ SUCCESS | >>>>> | |
| UT_Test | ✅ SUCCESS | >>>>> | |
| codecheck_style | ✅ SUCCESS | >>>>> | |
| pre-commit | ✅ SUCCESS | ||
| pre_comment | ✅ SUCCESS | >>>>> | |
| UT_Test_AI_review | ✅ SUCCESS | >>>>> | |
| ST_Test_A2 | ✅ SUCCESS | >>>>> | |
| ST_Test_A5 | ✅ SUCCESS | >>>>> |
[2026-09-03 19:07:06] CI执行结束


The following label is not ready.
lgtm: Please wait for committers to review the code.


描述
syntax error near unexpected token 'out_dir,'(line 736),安装中断;任意 tool 参数均触发(报错发生在解析期))与 heredoc 起始符写在同一行($( ... << 'TRAE_AGENT_PY' 2>/dev/null))。旧版 bash 解析时丢弃未完成的 heredoc,Python 正文被当作 shell 命令逐行解析,os.makedirs(out_dir,被误判为函数定义而报错。新版 bash(5.2+)仅输出警告且功能正常,导致 CI/开发环境未暴露)移到 heredoc 终止符之后(POSIX 规范写法,与仓内其余 20+ 处 heredoc 一致),逻辑零变化补齐两道版本无关看护,防止同类问题再次合入:
test-init-install.sh新增 Check 5,对所有插件 init.sh / example/init.sh 执行bash -n且要求 stderr 为空test-init-behavior.sh新增assert_no_shell_warnings,在 18 个真实执行 init.sh 的场景后断言输出不含 bash 解析诊断关联的Issue
Issue #608
测试
文档更新
类型标签
流水线故障排查