Skip to content

comsub heredoc shortcut drops cat's file operand: $(cat file <<EOF) returns the heredoc body, GNU returns the file (operand governs, heredoc is unread stdin) #1981

Closed

Description

@caomengxuan666

来源与复核

冗余清扫 R6 簇平价矩阵 h17 发现(改前即有、其簇按冻结纪律未动);主会话 2026-10-28 亲测坐实(fa170339 期二进制 vs GNU bash 5.3.20 oracle):

  • x=$(cat /tmp/f <<EOF … EOF):GNU got=[FILE-CONTENT],rubash got=[HEREDOC-BODY]。
  • 普通命令形 cat file <<EOF 两边同为 FILE-CONTENT——缺陷只在 comsub 词级 heredoc 捷径面:cat 带文件操作数时操作数优先、heredoc 只是不会被读的 stdin,捷径的准入却把该形收入并只回 heredoc 体。

修法方向与归宿

准入(PR #1980 刚统一的 heredoc_comsub_plan 即天然修点):cat 携非旗标文件操作数时 decline 捷径、走真实执行。归宿:comsub 准入后续批。回归钉:comsub 形断言取文件内容、多操作数与 cat - file <<EOF(- 读 stdin 的 GNU 语义)各一条对照。证据:~/workspace/clean-rubash-comsub/REPORT.md(parity h17)。

Activity

  1. added
    bug
    gnu-baseline
    P2-medium
    area:expansion
    on Oct 28, 2026
  2. added a commit that references this issue on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2-mediumarea:expansionbuggnu-baseline

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions