Skip to content

[bug] bind -s/-S macro listing prints control characters raw instead of canonical escapes #2872

Closed

Description

@caomengxuan666

症状

bind -s / bind -S 列出宏时,宏文本里的控制字符被原样输出(真实 LF / TAB / ESC / 0x18 字节),而不作 GNU 的 canonical 转义(\C-j / \C-i / \e / \C-x)。输出行会被真实换行打断。

最小复现

bind '"\C-x\C-t": "echo hi\n"'; bind -s
bind '"\C-x\C-t": "echo hi\n"'; bind -S

GNU 期望(oracle:自编译 GNU bash 5.3.20)

"\C-x\C-t": "echo hi\C-j"
\C-x\C-t outputs echo hi\C-j

rubash 实际(master c703f2d)

"\C-x\C-t": "echo hi<LF>"
\C-x\C-t outputs echo hi<LF>

(<LF> 为真实换行字节,od 核实;行被打断成两行。)

同向形态

  • 宏文本含 \C-j:GNU 回读 \C-j,rubash 真实 LF。
  • 宏文本含 \t:GNU 回读 \C-i,rubash 真实 TAB。
  • 宏文本含 \e:GNU 回读 \e,rubash 真实 ESC 字节(0x1b)。
  • 宏文本含 \C-x:GNU 回读 \C-x,rubash 真实 0x18 字节。
  • 纯文本宏:两壳一致。

定性

宏值本身两壳均已正确解释转义(存的是真实控制字符),分歧只在清单输出的转义:GNU 用 canonical 形,rubash 原样输出。键序一侧("\C-x\C-t")两壳转义一致。

Regression seed:

bind '"\C-x\C-t": "echo hi\n"'; bind -s
# GNU 期望:'"\C-x\C-t": "echo hi\C-j"'(单行,无真实换行字节)
bind '"\C-x\C-t": "echo hi\n"'; bind -S
# GNU 期望:'\C-x\C-t outputs echo hi\C-j'(单行)

Activity

  1. added
    bug
    on Nov 6, 2026
  2. added
    gnu-baseline
    area:interactive
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:interactivebuggnu-baseline

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions