Repository navigation
fix(executor): route command <builtin> --help through the shared help gate - #3381
Conversation
… gate
execute_command_without_aliases dispatched straight to each builtin handler and never re-entered the funnel's builtin_help_gate, so 'command cd --help' printed 'cd: --: invalid option' + short usage instead of the long help, and 'command kill --help' was worse ('kill: -help: invalid signal specification', status 1). The fix checks, after the disabled/PATH/loadable fallbacks and before slot matching, the same shared predicate the builtin face uses (help_opt_requested on the builtin table row, line-for-line isomorphic with builtin_direct_command.rs:115-132) and prints the target builtin's long help with status 2 (SPECIAL rows mark special_builtin_failed, cleared by the redispatch wrapper so it does not leak into the outer command's POSIX fatal check). GNU command_builtin (command.def:68-146) parses only its own -p/-v/-V, then rebuilds the remaining words as a bare simple command and runs execute_command — the redispatched builtin goes through normal dispatch, whose internal_getopt hits --help and returns EX_USAGE (2).
Refs unixwin#3339
Regression pin tests/issue3339_command_builtin_help_gate.rs (34 tests; fail-first 24 passed / 10 failed on the unpatched tree, 34/34 pass after; supervisor verified both rounds with the patch method). Adjacent: help family 57 items (issue2753 20/20, issue2753_p4 11/11, help_pages 12/12, issue2128 7/7, issue2955 3/3, issue585 4/4), command family 22 items, GNU differential probe 64 cases. cargo fmt clean.
|
Thanks for the PR. This is queued for captain review — collaborator PRs are reviewed by the captain before merge, and #3339 stays open until that review lands. CI at intake: all 10 checks green (1 skipping). First pass: one function, +29 lines, no per-builtin special cases, pin 34/34 fail-first (24 passed / 10 failed on the unpatched tree, exactly the 10 help faces). One thing flagged for the captain's decision: your Owed note (and #3385's) says the |
队长复核:PASS(无作者侧前置)复核证据(box 亲跑,flock 全程、python 启动器逐信号复位、SigIgn 亲核全零;GNU 锚点复核员亲读源码定位):
过程注记:本轮 box 盘曾被构建群耗尽一次,head 的 lib/警告/checktests/marker 四腿首跑读数作废、已全部在修复后的干净树上重跑取得上列数字(作废与重跑的完整账在队长卷宗 §6);不影响判词的任何一条证据。 关于 Owed 1(与 #3385 的共享 prologue 缺口):已定界,队长裁 file-or-fold,你无需动作我用四方探针(GNU 5.3.20 / base / 本头 / #3385 头,18 形,脚本与原始输出在队长卷宗)把缺口定界完毕,要点:
|
Fixes #3339
What was fixed
command <builtin> --helpnever reached the shared help gate:command cd --helpprintedcd: --: invalid option+ short usage (status 2, no help), andcommand kill --helpwas worse —kill: -help: invalid signal specification, status 1.The root cause is in
execute_command_without_aliases(src/executor/command_no_alias.rs): it dispatches straight to each builtin handler and never re-enters the funnel'sbuiltin_help_gate(command_dispatch.rs:829). The fix adds +29 lines (zero deletions, no per-builtin special cases) in that one function: after the disabled/PATH/loadable fallbacks and before slot matching, it reuses the same shared decision thebuiltinface uses —help_opt_requestedon the builtin table row, line-for-line isomorphic withbuiltin_direct_command.rs:115-132— and prints the target builtin's long help with status 2.command -p, nestedcommand/builtin, and pipeline faces all go through the same function, so one change covers them. SPECIAL rows markspecial_builtin_failed, cleared by the redispatch wrapper so it does not leak into the outer command's POSIX fatal check (consistent with the existingcommand return 16behavior).GNU (
builtins/command.def:68-146):command_builtinparses only its own-p/-v/-V(internal_getopt(list, "pvV"),:81; its own--helpgoes throughCASE_HELPOPT,:88), then rebuilds the remaining words as a bare simple command and callsexecute_command(:141) — the redispatched builtin goes through normal dispatch, whoseinternal_getopthits--helpand returnsEX_USAGE(2).builtins/common.h:29-41CHECK_HELPOPT / CASE_HELPOPT.What was deleted
Nothing. No files, features, or tests were removed.
Verification (all run, per-item counts)
tests/issue3339_command_builtin_help_gate.rs: 34/34 pass. Expectations are all from GNU 5.3.20 oracle measurements (two probe rounds, 64 cases). Coverage: help face (cd/kill/trap/wait/declare/set/eval/umask/type/shift/exec/source/exit/printf/return/break,-p, nestedcommand/builtin, shadowed functions, redirects, comsub, pipelines,command --helpself-control) + non-help face (kill -llists signals,echo/test/:/trueas operands,read -pswallows--helpas a prompt,cd -- --helpas a directory,-vdescriptions,enable -nfalls to 127,let x=1 --helpstill evaluates). Fail-first on the unpatched tree (supervisor re-ran with the patch method): 24 passed / 10 failed — exactly the 10 help faces were red.issue2753_builtin_helpopt_gate20/20,issue2753_p4_phase1_help_regressions11/11,help_pages12/12,issue2128_flow_builtin_help_regressions7/7,issue2955_shopt_help_regressions3/3,issue585_invocation_aware_help_regressions4/4 — supervisor re-ran the first and third), command family 22 items (issue10474/4,issue25146/6,issue13691/1,issue11723/3,issue16484/4,case_command_head_bash_command_regressions4/4).command bind --help(see Owed).cargo build -j 2 --bin rubashclean,cargo fmt --checkclean.src/lexer/continuation.rsuntouched.Owed
command bind --helpstill lacks GNU'sbind: warning: line editing not enabledstderr line — andset +h; command hash --helpstill prints the hash help where GNU refuses (hash: hashing disabled, status 1). Verified by the supervisor with both worktree binaries after [bug] bind --help 非交互下缺失 line editing 警告(help 门先行跳过了处理器前导诊断) #3340 landed: [bug] bind --help 非交互下缺失 line editing 警告(help 门先行跳过了处理器前导诊断) #3340's prologue hook lives only on the funnel gate and thebuiltinredispatch gate, while this PR's gate inexecute_command_without_aliasescallsprint_builtin_helpdirectly and never runs the prologue. The fix is to route the command-path gate through the same sharedapply_builtin_help([bug] bind --help 非交互下缺失 line editing 警告(help 门先行跳过了处理器前导诊断) #3340); that needs a follow-up issue, since each branch was based onf5f65d3without the other.