Skip to content

cold-path diagnostic prefixes derive from the argv[0] carrier chain (Refs #2791, #3193 census) - #3247

Merged
caomengxuan666 merged 3 commits into
masterfrom
fix/W-PREFIX-diag-prefix
Nov 10, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
fix/W-PREFIX-diag-prefix

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

本 PR 做了什么

诊断前缀普查(全仓站点裁定表在车道 REPORT)+ #2791 冷路径收敛修法:

  • 钉(先行提交 acca40e3):逐字取自波二纯钉 PR test: wave-2 pins I2 (Refs #2773 #2774 #2791 #2824) #3172 分支的 tests/issue2791_diagnostic_prefix_argv0.rs(7 格 / 26 断言形)。银行口径对账:MANIFEST 记该茎 fail-first 从未实测、钉头注自述为回归锁;本车道在现 master 实跑基底 ≡ 头树 = 7 passed / 0 failed(逐茎 test result 行在车道日志),与回归锁口径一致。
  • 修法(a2a92615):新建 src/builtins/prefix.rs 作为 builtin 层单一 argv[0] 派生源,逐字镜像执行器 error_report_name 的载体链(GNU error.c:90-120 get_name_for_error;shell.c:1779-1806 set_shell_name;builtins/common.c:83-96 builtin_error_prolog):最内层文件 → $0 逐字(BASH_ARGV0 载体)→ base_pathname(shell_name) → PROGRAM "bash",并补齐旧实现丢弃的单臂形。迁入站点:pwd 无效选项臂、pushd bindpwd_write、shopt compat44 只读诊断(err_readonly 族,gnu_errfmt 保留)、help/kill 进程 env 前缀、printf 两 env-map 前缀、exit/shift/shopt 的 stdio 入口 Prolog 名格。
  • 普查新分歧不在本 PR 修:main.rs 启动诊断族字面前缀(CLI 直达)等已逐条写成立案草案(复现 + GNU 5.3.20 实测 + 源码锚点)入车道 REPORT §6,交队长立。

本 PR 删除了什么

  • 删除 pwd / pushd / shopt / help / kill / printf 六处各自私有的 (script, line)-or-字面量前缀实现("bash: " / "rubash: " fallback 臂),统一改走新 builtins::prefix 链。
  • 删除 exit / shift / shopt 三处 stdio 入口 Prolog 里的 "rubash" 字面名格,改由载体链派生。
  • 未删除任何测试、文档或配置;与在飞 PR 文件面重叠的同漏斗站点(alias / declare / setattr / set / 共享 diagnostic.rs / exec)按撞车纪律未动,逐点记入 REPORT 裁定表与草案 G3。

验证

  • 头钉 7/7、基底 7/7(回归锁对账);邻茎 issue2714 7/7、issue1134 1/1;lib 1214 passed / 0 failed;RUSTFLAGS="-D warnings" cargo check rc=0;cargo fmt --check 全量 rc=0。
  • 邻茎 issue1768(2 红)与 issue1038(1 红)的基底对照与裁定见车道 REPORT §4。

Refs #2791
Refs #3193

W-PREFIX lane added 2 commits November 10, 2026 04:52
Nail taken verbatim from the wave-2 pure-pin PR branch
(test/wave2-pins-i2 @ 64209f6, the I2 stem for the argv0
diagnostic-prefix issue). Seven tests / 26 assertion shapes:
a renamed binary (argv[0] forced to "zimsh") must report every
builtin cold-path diagnostic under the argv[0]-derived name,
and script-form diagnostics under the script name.

GNU anchors: error.c:90-120 get_name_for_error (BASH_SOURCE[0],
else dollar_vars[0] verbatim, else base_pathname(shell_name),
else PROGRAM "bash"); shell.c:1779-1806 set_shell_name
(shell_name = argv0 verbatim); builtins/common.c:83-96
builtin_error_prolog.

Refs #2791
…carrier chain

The builtin layer's private prefix helpers each re-implemented
only the (script, line) arm of GNU's diagnostic prolog and fell
back to a hard-coded "bash: " / "rubash: " literal when either
arm was missing — a second voice beside the executor's
error_report_name chain, wrong for any shell invoked under
another name (renamed binary, embedding host) whenever a
builtin diagnostic reached the fallback with one arm absent.

New single source src/builtins/prefix.rs mirrors the executor
chain (error.c:90-120 get_name_for_error; shell.c:1779-1806
set_shell_name; builtins/common.c:83-96 builtin_error_prolog):
innermost file, else $0 verbatim (BASH_ARGV0 carriers), else
base_pathname(shell_name), else PROGRAM "bash" — with the
single-arm shapes the old helpers dropped ({file}: with no
line, {name}: line N: with no file). Migrated onto it: pwd's
invalid-option arm, pushd's bindpwd_write and shopt's compat44
readonly diagnostic (err_readonly family, gnu_errfmt kept),
help's and kill's process-env prefixes, printf's two env-map
prefixes, and the standalone stdio Prolog name cells of exit,
shift and shopt.

Sites in files owned by in-flight PRs (alias, declare,
setattr, set, the shared builtins/diagnostic.rs, exec) are
deliberately untouched here; the census table and the
follow-up drafts are in the lane REPORT.

Refs #2791
Refs #3193
@caomengxuan666 caomengxuan666 changed the title fix(builtins): cold-path diagnostic prefixes derive from the argv[0] carrier chain (Refs #2791, #3193 census) cold-path diagnostic prefixes derive from the argv[0] carrier chain (Refs #2791, #3193 census) Nov 10, 2026
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 10, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant