Skip to content

[bug] bind silently swallows malformed bind specs (no "no key sequence terminator" diagnostic) #2873

Closed

Description

@caomengxuan666

症状

bind 收到畸形绑定规约(缺 key sequence terminator)时,rubash 静默吞掉、不报 readline 诊断;GNU 报 readline: <规约>: no key sequence terminator(rc 仍为 0,两壳同)。

最小复现

bind 'backward-char' 2>&1; echo rc=$?
bind 'garbage' 2>&1; echo rc=$?

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

readline: backward-char: no key sequence terminator
rc=0
readline: garbage: no key sequence terminator
rc=0

rubash 实际(master c703f2d)

rc=0
rc=0

同向形态:经由 bind -q 的多余参数

bind -q 只查询首个函数名,其余参数按绑定规约逐条解析(builtins/bind.def 末尾的 rl_parse_and_bind 循环):

bind -q forward-char backward-char

GNU 先答 forward-char can be invoked via "\C-f", "\eOC", "\e[C".,随后 stderr 追加 readline: backward-char: no key sequence terminator;rubash 只答前半句、无诊断。顺序颠倒、同一函数两次、首参为未知函数时情形同向。

正对照(解析本身在工作,只丢失败诊断)

多余参数为合法规约时两壳同应用:bind -q forward-char '"\C-a": backward-char' 后 backward-char 键序含 \C-a;bind -q forward-char 'set bell-style none' 后 bind -v 读 set bell-style none。

GNU 法源

builtins/bind.def(其余参数按绑定规约逐条 rl_parse_and_bind)+ lib/readline/bind.c:1754 _rl_init_file_error ("%s: no key sequence terminator", string)。

Regression seed:

bind 'backward-char' 2>&1; echo rc=$?
# GNU 期望:stderr 含 "readline: backward-char: no key sequence terminator",rc=0
bind -q forward-char backward-char 2>&1
# GNU 期望:stdout 含 forward-char 键序,stderr 含 "readline: backward-char: no key sequence terminator"

Activity

  1. added
    bug
    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