Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

装完命令调不出来,先别怪命令:安装脚本三系统实测里修掉的 3 个坑

Description and use

The installation scripts for Claude and Codex CLI have been fixed to work correctly on Linux, macOS, and Windows: issues with variable parsing, command substitution initialization, old Codex version, and installation paths are resolved. After the fixes, the scripts pass CI tests and commands run successfully.

Problem

安装脚本在不同系统和 Bash 版本下出现变量解析、命令替换、旧版 Codex 静默失败等问题,导致命令无法正常调用。

Outcome

修复后脚本在 Linux、macOS、Windows 三系统均能通过 CI 绿色测试,命令可正常调用。

Workflow

  • 1. 运行 install.sh 或 install.ps1 以安装 Claude 和 Codex CLI。
  • 2. 脚本自动检查变量后跟非 ASCII 字符,使用 ${var} 形式。
  • 3. 预初始化 got=0 以避免 set -u 下命令替换错误。
  • 4. 检测 Codex 版本,若为 0.149.x 则打印升级警告。
  • 5. 根据 CLI 类型分流,复制文件到 ~/.claude/commands/.md 或 ~/.codex/skills/SKILL.md。
  • 6. 处理 frontmatter,去除 cli: 行。
  • 7. 运行自检:统计 Claude 目录文件数、Codex SKILL.md 数与命令文件数对比;抽查 frontmatter。
  • 8. 若验证失败,脚本报错并提示重试。
  • 9. 安装完成后可在新终端输入 /review 或 /onboard 进行功能验证。

Evidence

macOS 自带 bash 3.2 下,$var 后面紧跟中文或全角字符时,变量名边界解析会出问题,set -u 下会报 unbound variable。

Source

install.sh 开头是 set -euo pipefail。验证段里有一个 got=0 的预初始化,注释写明了原因:老版本 bash(如 macOS 自带 bash 3.2)对命令替换赋值的处理有怪癖,不先占位会在 set -u 下误报 unbound variable。

Source

install.sh 结尾有 codex 版本检查:如果检测到的 codex 是 0.149.x,会直接打印警告,提示这是已知会静默失败的旧版,请升级到 0.159+。

Source

  • Record date: 2026-11-04T05:28:54.018Z