Skip to content

[bug] P0 解析器: $(cmd <<< str) 嵌在双引号词内 = 致命 EOF 语法错误(rc=2 整脚本死)——生态脚本命令拼接形态 #168

Closed

Description

@caomengxuan666

现象(生态车道 target-ecosys5,asdf v0.15.0 find_cmd 触发)

$(命令 <<< 串) 形式的命令替换,当它嵌在双引号词内部时,niubash 直接报致命语法错误、整个脚本以 rc=2 中止;GNU bash 5.3.0 正常求值。

asdf v0.15.0 bin/asdf 的 find_cmd 是真实用户高频路径:

cmd_name="command-$(tr ' ' '-' <<<"${@:1:${args_offset}}").bash"

该行令 asdf 的 plugin/list/current/where/info 全部命令分发失效(fallthrough 到 "Unknown command")。

最小复现(双侧落盘 LF,WSL GNU Bash 5.3.0 vs niubash 8f89767)

# m2g.sh
echo "G:[$(cat <<< hi)]"
  • GNU: G:[hi],rc=0
  • niubash: m2g.sh: line 2: unexpected EOF while looking for matching ')',无输出,rc=2

类边界(已测矩阵)

形态 niubash
echo $(cat <<< bare)(裸词内) OK
v=$(cat <<< hi)(赋值 RHS,未加引号) OK
w="$(cat <<< "$*")"(赋值 RHS,整体加引号) OK
echo "G:[$(cat <<< hi)]"(双引号词内部) rc=2 致命
echo "M:$(cat <<< hi)!"(同上,无方括号) rc=2 致命
${@:1:N} / ${@:off} / ${arr[@]:1:2} 切片本身 OK(隔离排除)
纯 here-string cat <<< x(无 comsub) OK

即:here-string 出现在位于双引号上下文中的命令替换体内时,扫描器没有把 <<< 当重定向操作符消化掉,< 后的词吞掉了闭 ),报 unexpected EOF。

GNU 参考

here-string 是重定向词法(parse.y read_token_word 的重定向分支,<<< 产生 herestring 重定向);$( 在双引号内由 parse_matched_pair/parse_comsub 一路按操作符词法处理,<<< 与 ) 均应被识别。niubash 的引号内 comsub 扫描路径漏掉了 here-string 操作符。

产物

  • 复现脚本:D:/repo/rubash/target-ecosys5/m2g.sh、变体 m2a-m2m
  • 双侧产物:D:/repo/rubash/target-ecosys5/results/m2g/、results/m1/
  • 生态现场:results/p01-asdf/(asdf 命令分发全灭)

Activity

  1. added
    bug
    gnu-baseline
    on Sep 26, 2026
  2. caomengxuan666 commented on Sep 26, 2026

    @caomengxuan666
    MemberAuthor

    已在 52757ea 修复并关闭(6835852e):skip_parenthesized_unit_corrected 的 <<< 第二个 < 被误读为 << heredoc 吞掉 here-string 词和闭括号到 EOF——在 << 分支前消耗 <<<(镜像 skip_cmd_subst 已有逻辑)+ 运行时门与 driver 对齐。12 形态矩阵(含 asdf ${@:1:N} 切片形态)语义匹配;asdf v0.15.0 find_cmd 分发探测相同(dispatch-ok);-n 从 rc=2 转 rc=0 ×5 形态。continuation.rs 的同型潜在缺口作为可选加固 patch 移交 captain(已本地验证后回滚,patch 文件在原 worktree 内)。

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

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions