Skip to content

fix(scripts): convert macOS setup scripts from CRLF to LF - #195

Open
openjiuwen-sync-bot[bot] wants to merge 1 commit into
openJiuwen-ai:developfrom
openjiuwenai:sync/pr-1775
Open

fix(scripts): convert macOS setup scripts from CRLF to LF#195
openjiuwen-sync-bot[bot] wants to merge 1 commit into
openJiuwen-ai:developfrom
openjiuwenai:sync/pr-1775

Conversation

@openjiuwen-sync-bot

@openjiuwen-sync-bot openjiuwen-sync-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

Paired: GitHub #195GitCode !1775

What & Why

Closes #​1234.

The 7 shell scripts under
docs/zh/2.安装指导/本地安装/script/setup_scripts_macos/ were committed
with CRLF line terminators (edited on Windows). On Linux, \r is
interpreted as a literal carriage return — bash either refuses to run
the script or behaves erratically (phantom characters, broken
if/then parsing, heredoc corruption).

The sibling directory setup_scripts_linux/ and the scripts/ tree
are already clean LF, so this normalises only the macOS directory to
match — no behaviour change, no content change, line endings only.

Files converted (CRLF → LF)

File Lines
check_curl.sh 162
check_git.sh 202
check_mysql.sh 342
check_nodejs.sh 356
check_python.sh 948
fetch_codes.sh 224
setup.sh 4394

7 files, 3314 line-ending flips. Diff is purely \r\n\n.

Verification

  • find setup_scripts_macos -name '*.sh' -exec grep -l $'\r' {} \;
    → empty (no CRLF remaining) ✅
  • file setup.sh reports "Bourne-Again shell script ... executable"
    (previously: "...with CRLF line terminators") ✅
  • No content changes — every -CRLF +LF line pair is byte-identical
    modulo the trailing \r.

Issue #1234 reports that shell scripts under
docs/zh/2.安装指导/本地安装/script/setup_scripts_macos/ use CRLF line
terminators, making them unexecutable on Linux (`\r` interpreted as a
literal carriage return, bash refuses to run or behaves erratically).

The 7 affected files were edited on Windows and committed with CRLF;
the sibling setup_scripts_linux/ directory and the scripts/ tree are
already clean LF, so this normalises only the macOS directory to
match.

Converted (CRLF → LF):
  - check_curl.sh
  - check_git.sh
  - check_mysql.sh
  - check_nodejs.sh
  - check_python.sh
  - fetch_codes.sh
  - setup.sh

No content changes — line endings only.

Closes #1234

Co-Authored-By: AtomCode (GLM-5.2) <noreply@atomgit.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: 3ecb3abf953bf2bb71752d4bdf5052c38d52fd44

变更摘要

此 PR 将 docs/zh/2.安装指导/本地安装/script/setup_scripts_macos/ 目录下的 7 个 Shell 脚本文件的行尾从 CRLF\r\n,Windows 风格)统一转换为 LF\n,Unix 风格)。这些脚本原本在 Windows 上编辑提交,导致在 Linux/macOS 环境下 \r 被 bash 解释为字面回车符,可能引发脚本解析异常或执行失败。本次变更仅修改行尾符,不涉及任何代码逻辑或内容的改动,与同项目下已有的 setup_scripts_linux/scripts/ 目录的行尾规范保持一致。

主要改动

  • check_curl.sh 行尾转换:将 81 行 \r\n 转换为 \n,脚本逻辑(curl 安装检测、Homebrew 安装、功能验证)完全不变。
  • check_git.sh 行尾转换:将 101 行 \r\n 转换为 \n,Git 安装检测与验证流程保持不变。
  • check_mysql.sh 行尾转换:将 171 行 \r\n 转换为 \n,MySQL 配置检查、认证方式检测、数据库创建建议等逻辑不受影响。
- **`check_nodejs.sh` 行尾转换**:将 178 行 `\r\n` 转换为 `\n`,NVM 安装、Node.js 版本检测与网络连通性检查逻辑保持不变。
  • check_python.sh 行尾转换:将 474 行 \r\n 转换为 \n,Python 3.11 的多路径检测(Homebrew/pyenv/system)、pip 安装验证逻辑不受影响。
  • fetch_codes.sh 行尾转换:将 112 行 \r\n 转换为 \n,agent-studio 仓库克隆、分支切换、目录冲突处理逻辑保持不变。
  • setup.sh 行尾转换:将 2197 行 \r\n 转换为 \n,作为主安装脚本,其全部内容除行尾符外无任何变更。

@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: 3ecb3abf953bf2bb71752d4bdf5052c38d52fd44

代码审查

我已经完成了对所有 7 个文件的全面审查。以下是我的发现:

逐文件审查确认

check_curl.sh — 82 行,纯 \r\n\n 转换。内容逐字节一致(仅去掉末尾 \r)。原文件末尾缺少换行符,转换后已正常补上。

check_git.sh — 102 行,纯 \r\n\n 转换。内容一致。同样末尾补上了换行符。

check_mysql.sh — 172 行,纯 \r\n\n 转换。内容一致。

check_nodejs.sh — 179 行,纯 \r\n\n 转换。内容一致。GITHUB_STATUS / NVM_STATUS 的状态生命周期追踪:两者均为 else 分支内的局部变量,仅在当前块内定义-使用-消费,无跨文件引用,CRLF→LF 不影响其作用域和生命周期。

check_python.sh — 475 行,纯 \r\n\n 转换。内容一致。

fetch_codes.sh — 113 行,纯 \r\n\n 转换。内容一致。

setup.sh — 2197 行,纯 \r\n\n 转换。内容一致。(diff 展示中显示 "The file is empty" 仅为 4394 行 diff 的展示截断,实际文件完整且正确。)

结论

此 diff 为纯粹的 CRLF→LF 换行符转换,无任何逻辑变更、无内容变更、无新增代码。Grep 确认工作区 7 个文件中已无 \r 残留。转换使脚本在 Linux 上可直接执行,修复了原始 Bug #​1234。

审查结果:无问题发现。

优先级 数量
P0 0
P1 0
P2 0
P3 0

整体风险判断:无风险。 这是一个安全、干净的换行符规范化变更,建议合入。

类型 数量
🔴 阻塞 0
🟡 建议 1

💬 仅评论

@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: 3ecb3abf953bf2bb71752d4bdf5052c38d52fd44

TASK STATUS DETAILS
CodeCheck ✅SUCCESS Click here
AntiPoison ✅SUCCESS Click here
Software Composition Analysis ✅SUCCESS Click here
Npm Build ❌FAILED See CHECK tab
Ruff Check ✅SUCCESS See CHECK tab

FETCH_SCRIPT="${WORK_HOME}/fetch_codes.sh"
check_file "$FETCH_SCRIPT"

if ! retry_execute 3 10 "Fetch code" "bash '$FETCH_SCRIPT' '$GIT_BRANCH'"; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

head_sha: 3ecb3abf953bf2bb71752d4bdf5052c38d52fd44

🟡 Medium Priority

changed line 1556 及 retry_execute 函数(line 122–153)→ 受影响的边界:--branch= 命令行参数 → 失效模式: GIT_BRANCH 来自用户输入的 --branch=VALUE(line 1413),仅做了非空校验(line 1415),未过滤 shell 元字符(如 ';$() 等)。该值在第 1556 行以单引号包裹拼入传给 retry_execute 的命令字符串:"bash '$FETCH_SCRIPT' '$GIT_BRANCH'",随后在 retry_execute 的 line 135 被 eval 执行。如果攻击者传入 --branch="main'; rm -rf /; echo '",单引号会提前闭合,导致注入的命令被执行。

触发条件:脚本被自动化系统(CI/CD、webhook)以外部可控的分支名调用时,风险显著升高。手动运行时攻击者即用户本人,风险较低。

建议:方案一(推荐):不再将 $GIT_BRANCH 拼入 eval 字符串,改为直接在 retry_execute 中支持数组形式的命令传参,避免 eval。方案二(最小改动):在 --branch= 解析处增加字符白名单校验,例如 [[ "$GIT_BRANCH" =~ ^[a-zA-Z0-9._/-]+$ ]],拒绝包含 shell 元字符的输入。

@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: 3ecb3abf953bf2bb71752d4bdf5052c38d52fd44

TASK STATUS DETAILS
CodeCheck ✅SUCCESS Click here
AntiPoison ✅SUCCESS Click here
Software Composition Analysis ✅SUCCESS Click here
Npm Build ❌FAILED See CHECK tab
Ruff Check ✅SUCCESS See CHECK tab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants