Skip to content

fix(install): place_config_template bash 3.2 安全 — ${var} 加花括号避免后接全角字符被误判 unbound - #453

Merged
bigbrother666sh merged 1 commit into
TeamWiseFlow:masterfrom
bigbrother666sh:fix/install-place-config-bash32-reason
Jul 21, 2026
Merged

fix(install): place_config_template bash 3.2 安全 — ${var} 加花括号避免后接全角字符被误判 unbound#453
bigbrother666sh merged 1 commit into
TeamWiseFlow:masterfrom
bigbrother666sh:fix/install-place-config-bash32-reason

Conversation

@bigbrother666sh

Copy link
Copy Markdown
Member

macOS 用户 v5.6.0 升级模式跑到 [9/11] Placing config templatereason?: unbound variable(line 1174)。本地 Linux bash 5 同代码正常,差异在 macOS 自带 /bin/bash 3.2。

根因(真因,非 PR #451 误判的绑定坑):bash 3.2 在 C locale 下把未加花括号的 `` 后接多字节字符(全角()/→)的字节也算进变量名查找, 被查成 `reason)` → unbound,报错里 `?` 是全角 )的 C locale 渲染。PR #451 的预绑定是对错因下药(绑定从来没问题),花括号才是真修。

修法

  • place_config_template 内所有 $var 引用一律 ${var} 加花括号
  • 多字节标点改 ASCII:→ 改 ->,()改 ()
  • 每个变量单独 local 声明再纯赋值预绑(belt-and-suspenders,规避多变量一行 local 坑)
  • 顺手 brace 另 4 处同类风险引用(camoufox/weixin/awada warn、bind_weixin warn)

install.ps1 有 8 处类似但 PowerShell 原生 UTF-8 解析无此坑,不动。

重建 v5.6.0(不 bump patch)。

…被误判 unbound

macOS 用户 v5.6.0 升级模式跑到 [9/11] Placing config template 报
`reason?: unbound variable`(line 1174)。本地 Linux bash 5 同代码正常,
差异在 macOS 自带 /bin/bash 3.2。

根因(真因,非 PR TeamWiseFlow#451 误判的绑定坑):bash 3.2 在 C locale 下把
未加花括号的 `$var` 后接多字节字符(全角()/→)的字节也算进变量名查找,
`$reason)` 被查成 `reason)` → unbound,报错里 `?` 是全角 )的 C locale 渲染。
PR TeamWiseFlow#451 的预绑定是对错因下药(绑定从来没问题),花括号才是真修。

修法:
- place_config_template 内所有 $var 引用一律 ${var} 加花括号
- 多字节标点改 ASCII:→ 改 ->,()改 ()
- 每个变量单独 local 声明再纯赋值预绑(belt-and-suspenders,规避多变量一行 local 坑)
- 顺手 brace 另 4 处同类风险引用(camoufox/weixin/awada warn、bind_weixin warn)

install.ps1 有 8 处类似但 PowerShell 原生 UTF-8 解析无此坑,不动。
@bigbrother666sh
bigbrother666sh merged commit e6a95ac into TeamWiseFlow:master Jul 21, 2026
2 checks passed
@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.


codes-factory-of-bg seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@bigbrother666sh
bigbrother666sh deleted the fix/install-place-config-bash32-reason branch July 22, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants