Repository navigation
fix(main): derive startup diagnostics from argv[0] (#3254) - #3447
Conversation
Fail-first nails: src/main.rs startup diagnostics print literal bash:/rubash: instead of deriving the program name from argv[0] (-o/-O/-c/long-option/debugger family, plus the show_shell_usage block). GNU anchors: shell.c:1779-1806 set_shell_name, error.c:90-120 get_name_for_error, shell.c:1547-1566 start_debugger. Refs: #3254
Single startup_error_name (argv[0] verbatim, NIU_INVOKED_AS face first; empty stays empty, absent falls back to PROGRAM) shared by the option-parse family (-o/-O/-c/long-option/--profile-output diagnostics plus the show_shell_usage block, whose empty-argv[0] name rescues to bash per shell_name); driver-time diagnostics (debugger starter pair, init-file read failure) read the then-current $0 from the executor (BASH_ARGV0, rebound by the -c $0 operand and the script name before the drivers run). The --rcfile/--init-file missing-argument arm now prints the actual option name without dashes (init-file/rcfile) instead of always printing --init-file. GNU: shell.c:467 set_shell_name, shell.c:475/493/529 option parse, error.c:90-120 get_name_for_error, shell.c:863-867/874-881/519-528, shell.c:1547-1566 start_debugger, shell.c:1613 $0 rebinding, shell.c:2057-2103 show_shell_usage. Refs: #3254
PR #3447 复核评论稿(FAIL,未发,队长发)判词:FAIL — 产品对,钉错一处复核了 cron 车道 PR #3447(Refs #3254,头
产品是对的:本轮亲跑 GNU 5.3.20 精确形态( 返工范围(仅测试文件,产品码不动): 欠账(本轮双堵未跑,如实记):本地写墙关(内容写全堵,1MB 写 EPERM、git init 失败;1KB 写"成功"实为 0 字节静默丢弃)+ 盒盘 691M 空低于 1.2G 门——新钉 fail-first/17/17、lib 名集、 Owed:REPORT §5 相邻观察(缺失/不可读 |
) The debugger no-starter pair prints the script path, not `bash:`: GNU shell.c:1547-1566 carries the script name into the debugger-start diagnostics. The test wrapped arm B in `cli_normalized_text`, which only normalizes the harness's own exe path and must not wrap a script-path leader (its doc comment says so). Refs #3254
复核(重审第 3 轮):FAIL(钉-only 返工)队长复核(返工新头 5 败分解4 格 usage 格式( 队长裁断:钉的 4 处断言改归一化形 + 名。理由:归一化形是基底有意的既定行为,本 PR 范围是 argv0 派生名、不是 usage 格式;钉须断言产品既定行为。raw GNU 形与归一化形的取舍、以及 1 格 debugger 脚本名(钉 bug,必改):败在 stdout 断言( 已绿的面
Owed(返工后重审补齐)lib 双边名集、 返工要求钉-only:4 处 usage 断言改归一化形 + 名;1 处 debugger stdout 期望改 |
Re-review round 3 (captain comment 6837786757): pin head was 12/17. Four usage cells expected GNU raw Usage:\t form, but the product deliberately prints the normalized form (base src/main.rs:1389-1393: upstream suites sed the Usage:\t prefix away, so show_shell_usage prints the normalized form directly). Per the captain ruling (b), the pin now asserts the normalized form with the derived name, plus a negative guard against Usage:\t. The debugger script-name cell expected the raw script_arg path in stdout, but finish() normalizes stdout (scratch dir -> $S); expect script-0=$S/script.sh. Two pre-existing rustfmt reflows in the same file included (the file was fmt-dirty at the prior head). Refs #3254
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
【WIN-AGENT-AUDIT】 机制核查:
腿(X299 本机):
F 点回应:
续作记录:
未跑/VOID 的腿:
|
…s GNU does (Refs #3457) (#3549) GNU runs every startup file through builtins/evalfile.c:339 maybe_execute_file with FEVAL_ENOENTOK: ENOENT is not diagnosed (evalfile.c:120) and returns 0 (evalfile.c:130); EACCES and other open failures still go through file_error, and a directory is reported as `%s: is a directory` (evalfile.c:133-138). run_init_file diagnosed ENOENT and, on Windows, reported a directory as `Permission denied`. The diagnostic name prefix is untouched (PR #3447 owns it). Also rustfmt the d11 stem (master drift from #3511) so the fmt hook passes. Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Refs #3254
根因
src/main.rs启动期诊断族硬编码字面程序名(bash:/rubash:),不随 argv[0] 派生:-o/-O坏名、无效短选项、-c缺参、未知长选项、长选项缺参、--profile-output缺参、show_shell_usageusage 块、debugger starter 缺失对、init-file 读失败,共 11 处。另有两处名形差:run_args 的--rcfile/--init-file缺参臂恒印--init-file全名(GNU 印去横线名,且按实际选项分init-file/rcfile)。修法
启动期建单一名字源,全族共用:
run_main一次算出startup_error_name(argv[0] 逐字,NIU_INVOKED_AS 转发面优先;空名留空,缺失时回落 PROGRAMbash),逐层传参。usage 块用同一名字,唯空 argv[0] 时按shell_name救援为bash。driver_error_name:BASH_ARGV0 优先,空留空,缺失时回落调用名再回落bash)——-c的 $0 操作数与脚本名在驱动前已重绑 $0,与 GNU 一致。GNU 锚点
shell.c:467 set_shell_name、shell.c:475/493选项解析、shell.c:492 this_command_name = shell_name(-o 双名来源)、shell.c:529 this_command_name = NULL(-O 无第二名的原因)error.c:90-120 get_name_for_error(名 = $0 逐字;空 $0 停住不回落,见 空 argv[0] 调用时 $0 被种成 /、诊断印 /: …(GNU 印空名) #3355;缺失时 PROGRAM)shell.c:863-867长选项缺参(名去横线)、shell.c:874-881未知长选项、shell.c:519-528-c缺参、shell.c:1547-1566 start_debugger、shell.c:2057-2103 show_shell_usage、shell.c:1613脚本/-c$0 重绑myname/ 空 / 全路径 / BASH_ARGV0 导入 /-c$0 / 脚本形),脚本与日志见工作区probes/gnu-3254-oracle.sh与 REPORT。本 PR 删除了什么
src/main.rs中 11 处字面bash:/rubash:启动诊断前缀,改走单一派生源;删除show_shell_usage的字面bashusage 行首。--rcfile/--init-file缺参臂恒印--init-file的名形(改印实际选项去横线名)。docs/api-ledger.md;未碰src/lexer/continuation.rs。既有测试期望更新
tests/issue547_bash_o_listing_regressions.rs、tests/issue106_107_108_regressions.rs:旧期望写死bash:,改为 harness 二进制路径(argv[0] 逐字,GNU 同理)。tests/cli_tests/bashdb_compat.rs:debugger 对期望改走cli_normalized_text(路径归一为bash,与套件既有口径一致)。tests/issue3254_main_rs_argv0_diagnostics.rs(17 格,argv[0] 变体全族)。相邻观察(未修,待队长立案)
GNU 对缺失/不可读的
--init-file/--rcfile文件保持静默(无诊断、继续执行 rc 0),产品run_init_file则打印诊断并返回 1。本 PR 只修该诊断的名字,不改其触发与否。验证状态
UNVERIFIED-BY-CAPTAIN
RUSTFLAGS="-D warnings"check、hygiene + fmt。