Repository navigation
fix(bind): r74 bind-face batch — set validation, listing untranslate, malformed-spec diagnostics (Refs #2871, Refs #2872, Refs #2873, Refs #2874) - #2913
Merged
Conversation
) rl_variable_bind (lib/readline/bind.c:2056) reports a value whose setter returns nonzero — `readline: NAME: could not set value to `V'` (bind.c:2073) — and keeps the old value. rubash classified bell-style as a free-form string (it stored `bogus` itself) and let the keymap arm swallow unknown names silently. - New VariableKind::BellStyle arm porting sv_bell_style (bind.c:2227): none/off, audible/on, visible, empty → audible, case-insensitive; anything else is CouldNotSetValue. The value reads back as the preference's name, so `on` → audible and `off` → none in `bind -v`. - Keymap arm ports sv_keymap (bind.c:2185): the name must resolve through rl_get_keymap_by_name (names at bind.c:2404, case-insensitive at bind.c:2424) or the set is rejected loudly; valid names store the canonical map name as before. - Variable names resolve case-insensitively like find_boolean_var / find_string_var (_rl_stricmp) and every arm stores under the canonical table name; diagnostics keep echoing the name as typed. Both `set` channels inherit the fix (bind arguments and inputrc lines). The in-repo unit pin that asserted the silent keymap behaviour came from a probe that never captured stderr and is corrected; the SetVariableOutcome doc no longer claims only editing-mode rejects. Pins: tests/issue2871_bind_set_validation_regressions.rs (6 tests; fail-first on master 5 failed / 1 passed).
…2872, Refs #2874) bind -s/-S printed stored macro text raw — a real LF split the listing line, TAB/ESC/0x18 went out as raw bytes — and bind -X did the same to -x commands, inner quotes breaking the listing's quoting. GNU passes every listed value through _rl_untranslate_macro_value (lib/readline/bind.c:722, use_escapes=0) before printing: rl_macro_dumper at bind.c:2842 for macros, and print_unix_command_map (bashline.c:4729) through the same dumper for -x commands. - Faithful port `untranslate_macro_value`: meta → \M- + unmeta'd rendering, ESC → \e, control → \C-x (lowercased UNCTRL), DEL → \C-?, and \ / " backslash-escaped, so a listing line never carries a raw control byte and re-parses to the stored value. - Applied to format_macro_readable / format_macro_plain (#2872) and format_unix_command_readable (#2874) — one commit for both issues because the three formatters are one mechanism sharing a single diff hunk. #2874's storage half did not reproduce on current master: the colon form already stores the command verbatim (the rl_generic_bind path, bashline.c:4898-4900) and the whitespace form already translates (rl_macro_bind, bashline.c:4893). The #2874 pins prove storage through the listing byte-for-byte — a stored backslash-n lists as \\n where a stored LF would list as \C-j. Pins: tests/issue2872_bind_macro_listing_regressions.rs (5 tests; fail-first 4/1) and tests/issue2874_bind_x_listing_regressions.rs (5 tests; fail-first 0/5), plus a unit pin for the port itself.
…Refs #2873) The positional loop dropped every non-quoted, non-set argument wholesale, so the diagnostics rl_parse_and_bind (lib/readline/bind.c:1594) issues for malformed specs never fired: a bare token (`bind 'backward-char'`) was swallowed instead of reported as `no key sequence terminator` (bind.c:1754), including when it arrived as an extra argument after `bind -q NAME` (builtins/bind.def:308-312 runs every remaining argument through rl_parse_and_bind and ignores its return, so rc stays 0). - New `unquoted_spec_diagnostic` ports the separator scan's two diagnostic outcomes for non-quoted specs: separator-first → `` `%s': invalid key binding: missing key sequence `` (bind.c:1637); no separator anywhere → `%s: no key sequence terminator`. Shapes GNU absorbs silently stay silent: empty text, `#` comments, separator-carrying old-style specs (`bind 'ls -l'`). - `bind 'set'` alone (and `bind 'set '`) enters the variable path with an empty name in GNU and now reports `readline: : unknown variable name` instead of dropping silently. - The missing-closing-quote-for-macro message gains GNU's backtick/apostrophe frame (bind.c:1731); the stale unit expectation is corrected with it. Pins: tests/issue2873_bind_malformed_spec_regressions.rs (8 tests; fail-first on master 6 failed / 2 passed).
caomengxuan666
marked this pull request as ready for review
November 6, 2026 15:06
… (captain) The UTF-8 boundary hygiene gate rejects the `as u8 as char` widening in untranslate_macro_value; spell it char::from(u8) — the byte value is the code point by construction (UNCTRL of a C0 control char), so behaviour is unchanged. Found by the captain when PR #2913's CI failed the hygiene step in 10s with all test steps skipped; the four stems and the full lib suite were re-verified locally before this commit.
Member
Author
|
Captain note (2026-11-06): local verification passed — stems issue2871 6/6, issue2872 5/5, issue2873 8/8, issue2874 5/5; full lib 1140/0/3. CI's "Rust tests" failure on 5ab5730 was the UTF-8 boundary hygiene step (all test steps skipped): one unreviewed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
r74 差分巡猎的 bind 面四单一批次修复(UNVERIFIED-BY-CAPTAIN:队长复核前不作已验证计)。
Fixes #2871
Fixes #2872
Fixes #2873
Fixes #2874
逐单
#2871 —
bind 'set …'静默接受 bell-style/keymap 非法值根因在
apply_readline_variable的 setter 分发:bell-style被归为自由字符串(非法值直接存下),keymap 臂对未知名字静默返回 Applied。按 GNU 法源修:rl_variable_bind(lib/readline/bind.c:2056):setter 返回非零 →readline: NAME: could not set value to `V'(bind.c:2073)、旧值保留。VariableKind::BellStyle臂移植sv_bell_style(bind.c:2227):none/off、audible/on、visible、空值→audible,大小写不敏感;回读为枚举名(on→audible、off→none)。sv_keymap(bind.c:2185):名字须经rl_get_keymap_by_name(bind.c:2404 八名,bind.c:2424 大小写不敏感)解析,否则 CouldNotSetValue;合法名仍存 canonical 名。find_*_var的_rl_stricmp大小写不敏感匹配,存储一律落在 canonical 名下(诊断仍回显原样输入的名字)。set通道(bind 参数与 inputrc 行)共用此分发,一并生效。仓内一枚旧单测钉(断言 keymap bogus 静默)源于一次未捕获 stderr 的探针,已随本单改正;SetVariableOutcome文档同步纠正。#2872 —
bind -s/-S宏清单原样输出控制字符根因:
format_macro_readable/format_macro_plain直插存储文本。GNU 在 bind.c:2842 处先经_rl_untranslate_macro_value(bind.c:722,use_escapes=0)。新增该函数的忠实移植untranslate_macro_value(META→\M-、ESC→\e、CTRL→\C-x、DEL→\C-?、\/"反斜杠转义),应用到两个宏格式器。#2874 —
bind -X不转义 -x 命令串与 #2872 同一机制:
print_unix_command_map(bashline.c:4729)经同一个 dumper 打印,故format_unix_command_readable同样过untranslate_macro_value(与 #2872 同一提交:三个格式器同属一个机制、同一 diff hunk,不可分)。存储半边在当前 master 上不复现:冒号形已按
rl_generic_bind(bashline.c:4898)原样存储、白空格形已按rl_macro_bind(bashline.c:4893)定义期转义;本单钉子以清单字节证明存储(存\n两字符清单作\\n,存真实 TAB 清单作\C-i,两假设在输出上可区分)。#2873 — 畸形 bind 规约被静默吞掉
根因:executor 位置参数循环对非引号非
set参数整批忽略,rl_parse_and_bind(bind.c:1594)的校验诊断永不触发。unquoted_spec_diagnostic移植分隔符扫描的两个诊断结局:分隔符开头 →`%s': invalid key binding: missing key sequence(bind.c:1637);全串无分隔符(foundsep==0)→%s: no key sequence terminator(bind.c:1754)。bind -q NAME之后的多余参数同经此路(bind.def:308-312,rc 不变)。GNU 静默吸收的形态保持静默:空串、#注释、带分隔符的 old-style 规约(bind 'ls -l')。bind 'set'(及bind 'set ')在 GNU 进入空名变量路径,现报readline: : unknown variable name。本 PR 删除了什么
无产品代码删除。删除/改写的只有错误断言与过期注释:
set_variable_outcomes_match_gnu_probes中「keymap bogus 静默」的错误钉及其依据注释、SetVariableOutcome文档中「只有 editing-mode 会响亮拒绝」的过期断言、宏缺闭引号单测的错误期望文本、位置参数循环上方「非引号文本一律静默」的过期注释。净行数
+647 / −35(6 文件:src/builtins/bind.rs、src/executor/bind_builtins.rs 与四枚新钉)。其中产品代码 +243/−35 量级,其余为回归钉。
验证(车道自验,队长未复核)
cargo check --locked --all-targets绿;触及文件已 rustfmt。~/workspace/fix-r74/probes/,GNU 期望全部取自自编译 GNU bash 5.3.20。残差(已写入车道 REPORT,待队长裁)
bind 'Control-t: transpose-chars'在 GNU 真绑定,rubash 静默丢弃;bind 'backward-char '(尾随空格)在 GNU 报unknown key modifier。需 old-style keyname 翻译 machinery,超出本批诊断范围,本批对带分隔符的 old-style 规约保持静默而非半吊子诊断。bind 'set: foo':GNU 分隔符扫描在:截断、token 即set,报foo: unknown variable name;rubash 的 strip_set_keyword 要求set后空白,此规约落入静默类。-mkeymap 名校验大小写敏感(GNU 为不敏感),既有行为,在 [bug] bind set silently accepts invalid bell-style/keymap values (no "could not set value" diagnostic) #2871 的set范围之外。