Skip to content

[engine] 语法误拒族:extglob @(/for hash/函数定义——官方资产 54 例被拒而 GNU 接受 #452

Closed

Description

@caomengxuan666

证据源

scripts/harvest/snapshots/wt92-local-20261005/test-results.jsonl(verdict=SYNTAX-REJECT-RUBASH-ONLY,54 条:niu -n 拒绝、GNU bash -n 接受)。全部来自官方/主流资产,不是野生脏脚本:

集群 1:extglob 模式出现在补全/条件上下文被拒(约 30+ 条,最大头)

scop/bash-completion@00c3461 官方文件(7z、cvs、ps 等):

  • -?(a)[ix]*)、-*@([aAbcelmnNosu]|t-))、?(-)p | [^-]*p | --pid) → syntax error near unexpected token '('

ohmybash/oh-my-bash@abf8461 lib/cli.bash:plugin::@(disable|enable|load))

特点:?( @( 出现在 case-glob/[[ ]] 或词首位置。与 #424(>?(zz)out 重定向目标 extglob)同族——extglob 词法在非重定向上下文同样失效。修一处词法即可批量关闭。

集群 2:for hash … 关键字冲突(ohmyzsh changelog.sh)

for hash rhash in ${(kv)reverts}; do → rubash 拒 do。hash 是我们的内建名,被当成保留字处理了;GNU 中 hash 只是普通标识符。同理检查其它内建名(type/readonly/local…)是否被 lexer 保留。

集群 3:名称 () { 函数定义行被拒(ohmyzsh check_for_upgrade.sh)

() { 附近报语法错——需甄别:该文件同时出现在 GNU-ALSO-FAILS(zsh 方言片段),可能只有部分行是真误拒;修复时先按行拆出 GNU 接受的最小样本。

为什么值得修

这 54 个文件是 bash-completion、oh-my-bash、ohmyzsh 的官方资产——它们不跑通,niu setup 选 full 后的用户首体验就是刷错误(见 #209 的 setup 五连败同款背景)。

验收

  • 上述三个官方仓的指定文件 bash -n 级通过(GNU 接受的行全部接受)
  • eco-test 重跑 54 条,SYNTAX-REJECT-RUBASH-ONLY 归零(除真 zsh 方言)

Activity

  1. added
    P2-medium
    bug
    on Oct 9, 2026
  2. caomengxuan666 commented on Oct 10, 2026

    @caomengxuan666
    MemberAuthor

    集群清账:集群1(赋值前缀+子shell)#453 修复;「for hash」实为 zsh 多变量语法非 bug;函数定义名 $( ) 由 #476 修复;extglob 重定向拒绝由 wt63 实现并经 #464 锁定;() { 行被 #120 线解决并经 #459 钉死。54 例官方资产现全部按 GNU 语义接受/拒绝。

  3. caomengxuan666 commented on Oct 12, 2026

    @caomengxuan666
    MemberAuthor

    重审计(2026-10-12,niubash 分支 eco/reaudit-20261010 台账)对本单 54 条记录 / 39 个唯一资产的逐条定案,与本单收尾结论一致并补充量化:

    台账与逐条证据见 niubash PR(eco/reaudit-20261010)scripts/harvest/snapshots/reaudit-20261010/。

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2-mediumbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions