Skip to content

fix(builtins): typeset listing hides unmaterialized BASH_ARGV0 and renders GROUPS from its cell (Refs #3026) - #3702

Closed
caomengxuan666 wants to merge 1 commit into
masterfrom
fix/3026-typeset-bash-argv0-groups
Closed

caomengxuan666 wants to merge 1 commit into
masterfrom
fix/3026-typeset-bash-argv0-groups

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

根因

列表应渲染存储 cell,按名读才物化 cell。GNU(variables.c):BASH_ARGV0 是 value cell 为 NULL 的动态标量(variables.c:1850),只有 find_variable(variables.c:1175-1189)按名查找才调 get_bash_argv0 把值绑进 cell;GROUPS 是空数组,直到 get_groupset(variables.c:1637-1655)被查找时填入元素;枚举 print_var_list(variables.c:1066)从不触发 getter;var_isset==0 的变量不打印(variables.c:1096-1104),空数组印 GROUPS=()(arrayfunc.c:1239)。

#2997 修了 pristine 面,但物化链是断的:

  • GROUPS:declare-form 的 view 调自由函数 groups_words(),只渲染、不置 groups_materialized,于是 declare -p GROUPS 后随后的 typeset 仍印 GROUPS=()(GNU 印 ([0]=\"0\"))。
  • BASH_ARGV0:dynamic_parameter_value 明确不缓存它,列表用静态 invisible 标记永远隐藏——按名读/展开读后 GNU 显示值,rubash 仍不显示。

另正名:BASH_ARGV0 在 GNU 里没有 att_invisible(variables.c 全文无对其 VSETATTR)。#2997 的静态标记模型在 pristine 态与 GNU 等价,物化后是错的。

GNU 锚点

  • variables.c:1850 INIT_DYNAMIC_VAR("BASH_ARGV0", NULL, get_bash_argv0, assign_bash_argv0)
  • variables.c:1886 init_dynamic_array_var("GROUPS", get_groupset, ...)
  • variables.c:1637 get_groupset;variables.c:1175-1189 find_variable_internal(按名查找才调 dynamic_value)
  • variables.c:1066 print_var_list;variables.c:1096-1104 print_assignment(var_isset==0 不印)
  • arrayfunc.c:1239 print_array_assignment(空数组印 ())
  • declare.def:373-380 无参 declare 分派 set_builtin;setattr.def:484-530 declare -p 裸名渲染

改动

  • src/executor/dynamic_arrays.rs:dynamic_parameter_value 缓存 BASH_ARGV0 的 live 值作 cell(存在=已物化;表值仍是 live $0 载体);declare-form GROUPS 臂改调 self.groups_words()(置 groups_materialized);dynamic_set_views 物化后追加 BASH_ARGV0 标量供应;dynamic_cell_view 的 provider 标量表加入 BASH_ARGV0(物化后渲染值,未物化渲染裸名)。
  • src/builtins/set.rs:DynamicSetView 增加 scalar 位;print_shell_variables 按位渲染标量/数组,供应名字豁免 invisible 跳过。
  • src/executor/declare_local.rs:listing 构造的标量块加入 BASH_ARGV0。
  • tests/issue3026_typeset_listing_argv0_groups.rs:新增 2 钉(命名读后 declare -p 列表显示物化值;展开读物化 BASH_ARGV0 进随后列表),既有 3 钉不动。

本 PR 删除了什么

  • 删除了 dynamic_parameter_value 旧注释中“table-backed BASH_ARGV0 不缓存”的排除口径(该模型是本单根因之一)。
  • 删除了 declare-form GROUPS 臂对自由函数 groups_words() 的调用(改调置位的方法 self.groups_words())。
  • 删除了 declare_local.rs 旧注释“BASH_ARGV0 没有 dynamic view”的说法。
  • 未删除任何文件、公开 API、用户可见行为;唯一被移除的行为就是本单修掉的错误行为(BASH_ARGV0 读后仍永不显示;GROUPS 命名读后不粘住)。

验证

UNVERIFIED-BY-CAPTAIN。 构建槽全断:Simular box 冬眠且钱包为空(box_ensure:top up at https://box.simular.ai/billing,需用户充值);老服务器与 X299 路由均经 box,故同断;本 VM 按规矩不本地构建。以下腿全部欠账,待槽恢复后补跑:钉 stem(5 钉,含 fail-first 复核)、全量 lib 与 base 逐数对齐、邻域 stem(#2973/#2700/#1046)、RUSTFLAGS="-D warnings" cargo check --locked --lib --bins、hygiene。已做的非构建核查:cargo fmt --check 4 文件 rc=0;probe-battery 三轮 ALL PASS(15:37/16:04/16:12 UTC)。CI 绿不等于钉绿(ci.yml nextest 表无新钉 stem),仅作编译信号。

已知残差(另单处理):source 内物化、算术 resolve() 路径、COMP_WORDBREAKS 同机制未覆盖、declare BASH_ARGV0=<值> 绑定前物化、unset 后重绑 invisible 残留。详见工作区 REPORT(不入仓)。

Refs #3026

…nders GROUPS from its cell (Refs #3026)

Root cause: listings must render the stored cell; a by-name read binds
(materializes) it. GNU (variables.c:1850/1886/1637/1175-1189, 1096-1104):
BASH_ARGV0 is a dynamic scalar with a NULL value cell until find_variable
binds it; GROUPS is an empty array until get_groupset fills it; the
enumeration (print_var_list, variables.c:1066) never fires the getter.

#2997 fixed the pristine faces but left the materialization chain broken:
- GROUPS: the declare-form view called the free groups_words() without
  setting groups_materialized, so a named read did not stick into later
  listings; now the method self.groups_words() is used.
- BASH_ARGV0: dynamic_parameter_value explicitly did not cache it, and
  the listing hid it with a static invisible mark forever; now a by-name
  read caches the live value as the cell, the set-form listing renders it
  once materialized, and the declare-form renders it valued (bare while
  the cell is NULL).

Nails: tests/issue3026_typeset_listing_argv0_groups.rs - 2 new tests
(declare -p listing shows materialized values after named reads;
expansion read materializes BASH_ARGV0 into later listings) on top of
the 3 pre-existing nails from #3169.

UNVERIFIED-BY-CAPTAIN: no build slot available (Simular box wallet empty;
X299/old-server routes transit the box). No test leg has run; CI on the
draft PR is the only compile signal.
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】PR #3702 第1轮 — 建议:PENDING(CONFLICTING/DIRTY,且已被 #3708 取代;内容腿全绿)

head: a13bc85 base(merge-base): e81a1af 文件: 4 个 +148/-22
关联 issue: #3026(状态:closed,2026-11-15T16:52:58Z,由 PR #3708 的 squash 04495715 以 completed 关闭;我核过的时间:2026-11-16 本地)

重复实现:master 已含 04495715 fix(executor): by-name BASH_ARGV0 reads materialize the listing cell (Refs #3026) (#3708)(git merge-base --is-ancestor = yes),其改动与本 PR 的 dynamic_arrays.rs / set.rs 段逐行同形(同一 scalar 位、同一 BASH_ARGV0 缓存臂);本 PR 多出的只有 2 个钉(expansion 读、declare -p listing)。作为 superseded 的重复 PR,本 lane 不合不关,请队长决定关闭或只保留额外 2 钉。

机制核查:

  • 与 GNU 一致:variables.c:1850 INIT_DYNAMIC_VAR("BASH_ARGV0", NULL, get_bash_argv0, assign_bash_argv0)(NULL value cell → 列表不可见,直到按名读触发 getter);variables.c:1637 get_groupset / 1886 init_dynamic_array_var("GROUPS", ...)(按名读才生成元素);variables.c:1066 print_var_list、1096-1104 print_assignment(var_isset==0 不印);arrayfunc.c:1239 print_array_assignment(空数组印 ())。PR 的「只按名读物化、列表渲染缓存 cell、GROUPS 走置位方法」与该模型一致,非翻译层。
  • 无语义可疑/无关改动;src/builtins/set.rs 的 invisible 豁免只对「执行器显式供应的名字」生效,与 GNU「cell 存在即可见」等价。
  • 冲突面:git merge-tree --write-tree origin/master a13bc85d → CONFLICT 于 src/builtins/set.rs、src/executor/declare_local.rs、src/executor/dynamic_arrays.rs 三文件(master 已有 fix(executor): by-name BASH_ARGV0 reads materialize the listing cell (Refs #3026) #3708 的同区改动,必然冲突)。

腿(逐项):

  • 钉自跑(head a13bc85):issue3026_typeset_listing_argv0_groups 5 passed / 0 failed。
  • fail-first(base e81a1af,钉文件原样放入):2 passed / 3 failed,红名 = {declare_p_listing_shows_materialized_values_after_named_read, expansion_read_materializes_bash_argv0_into_later_listings, named_reference_materializes_groups_and_bash_argv0_into_later_listings};2 个 base 绿的是 pristine 面边界锁(防过度隐藏),非废钉。
  • lib 双边:head {api::consumer_tests::issue2084_session_end_restores_host_process_state}(1351 passed / 1 failed)/ base e81a1af {同一测试}(1351 passed / 1 failed)/ 差集 ∅。
  • -D warnings:RUSTFLAGS="-D warnings" cargo check --locked --lib --bins → 0 警告。
  • 卫生:rustfmt 4 文件全 clean;marker-lint OK (117 registry consts, 268 allowlisted);utf8-boundary clean。
  • CI(head a13bc85, run 43734564362 / 43734564320):红任务 4 个,逐个归因——Rust tests / Rust tests (macOS) / GNU regression goldens and canaries 唯一红格 = api::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell(已知基线);niubash builds against this tree = MISSING session-method rubash::api::Session::cwd(master 已由 58eeb88c/docs(ledger): record Session::cwd #3704 记录,stale-base,非本 PR)。
  • GNU 对照(WSL /usr/local/bin/bash 5.3.20(1)-release,脚本文件形态,探针 target/audit-s5/p3702/g1.sh):
    • pristine typeset | grep ^BASH_ARGV0= → GNU 无行(rc=1);typeset | grep ^GROUPS= → GNU GROUPS=();本 PR 钉 1 断言同值;
    • pristine set 面同值(钉 2);
    • 链 declare -p GROUPS; typeset | grep ^GROUPS=; declare -p BASH_ARGV0; typeset | grep ^BASH_ARGV0= → GNU declare -a GROUPS=([0]="0") / GROUPS=([0]="0") / declare -- BASH_ARGV0="chain.sh" / BASH_ARGV0=chain.sh(钉 3 同值);
    • declare -p 列表链(钉 4)与 echo "$BASH_ARGV0" 后列表(钉 5)→ GNU 与钉期望逐字节一致(seen:exp.sh + BASH_ARGV0=exp.sh)。

F 点:无(语义面)。

阻塞项(不合并的原因):

续作记录:无(未改代码;PENDING 不合不关)。
未跑/VOID 的腿:无。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】PR #3702 第2轮 — 建议:PENDING(superseded;建议 owner 关闭本 PR)
head: a13bc85(未变)base(merge-base): e81a1af
关联 issue: #3026(状态:closed / COMPLETED @ 2026-11-15T16:52:58Z,由 #3708 squash 04495715 关闭;我核过的时间:2026-11-16 本地)

T 波处置(收尾波,分工 t4):

未跑/VOID 的腿:本轮未重跑(重复实现处置优先)。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
Z3 波第 3 轮 — 建议:PENDING(superseded;建议 owner 关闭本 PR,不返工)

head: a13bc85(未变)
关联 issue: #3026(状态:CLOSED / COMPLETED @ 2026-11-15T16:52:58Z,由 #3708 squash 04495715 关闭;本轮复核时间:2026-11-17 04:5x UTC)

本轮复核(Z 波,收网第四轮):

未跑/VOID 的腿:本轮未重跑(重复实现处置优先;前轮腿结论存档见第 1/2 轮评论)。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】superseded 建议关闭

本 PR 对应 issue #3026 已 CLOSED,修复面已由 #3708 落地(master 已含)。

建议:owner 关闭本 PR,不返工。若需保留钉面,请单独提钉 PR。
(按调度口径:agent 不关 PR,只给建议。)

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】superseded 建议关闭

f3 车道复核(2026-11-17 19:5x +08,master a41909d):

建议:owner 关闭本 PR,不返工。若需保留钉面(本 PR 比 #3708 多 expansion 读 / declare -p listing 2 格),请单独提钉 PR。
(agent 不关 PR,只给建议;与 2026-11-17T04:58Z 已发评论结论一致,本条为复核存档。)

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