Repository navigation
Refs #3108 - #3140
Merged
Merged
Refs #3108#3140
Conversation
…(Refs #3108) GNU binds att_exported only on entries that arrive via the process environment (variables.c:511-518 initialize_shell_variables); its own cells (variables.c:1010 make_vers_array, variables.c:1882 init_dynamic_array_var for DIRSTACK) are born unexported. The pin asserts seeded names snapshot exported=false, inherited PATH/HOME snapshot exported=true, declaration text keeps its shape, and the write paths are unchanged. On the base tree only the seeded cell fails (3 passed / 1 failed).
…venance (Refs #3108) Executor::new and the fresh-shell rebuild in external_finish bound the whole seeded env table via VariableStore::from_environment, which marks every entry exported. The table already knows per-entry provenance: initialize_fresh_shell_env_vars marks only genuine environment imports exported (mark_initial_exported_vars) and seeds the shell's own names (BASH_VERSINFO, DIRSTACK, BASH_ALIASES, BASH_CMDS, ...) after the sweep, so the seeds are unexported on the table side while the snapshot reported them exported=true through capture_variable's merged_attrs. New VariableStore::from_var_table binds each entry's `exported` from the table's own attr record; both executor birth sites switch to it. from_environment is retained: its blanket-exported contract is correct for a raw process-environment map. GNU: variables.c:511-518 (initialize_shell_variables binds only environment arrivals att_exported|att_imported); variables.c:1010 (make_vers_array binds BASH_VERSINFO readonly only); variables.c:1882 (init_dynamic_array_var registers DIRSTACK with attrs 0).
# Conflicts: # src/executor/external_finish.rs
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.
Refs #3108
问题
Session 快照(
views().inspection())把全部启动种子名报attrs.exported = true,包括 BASH_VERSINFO、DIRSTACK、BASH_ALIASES、BASH_CMDS 等 GNU 从不导出的名字。env 表侧同名 attrs 为exported: false,declare -p文本不受影响。根因
Executor::new先经initialize_fresh_shell_env_vars把种子整表写入 env 表,再以VariableStore::from_environment(&env_vars)建 typed store,后者把整表无区别绑成 exported Scalar;capture_variable的merged_attrs把 typed 的 exported 或入快照。真实进程环境条目 exported=true 无误,种子条目被一并打标才是误报源。external_finish的 fresh-shell 子壳重建是同一形状的第二落点。GNU 出处是逐条的:只有经进程环境到达的条目才带 att_exported|att_imported(variables.c:511-518);壳自身单元生来不带(variables.c:1010 make_vers_array;variables.c:1882 init_dynamic_array_var 以 attrs 0 注册 DIRSTACK)。
修法(队长裁定方案 i)
在绑定的源头定对:typed store 改从 VarTable 按其 attrs 出处绑定(exported 取表侧 attr_of),两个 from_environment 调用点(init 出生、external_finish fresh-shell)一并切换。不在 capture 合并规则处打补丁。
本 PR 删除了什么
删除
VariableStore::from_environment在两个 executor 调用点上「整表无区别 exported」的绑定语义——该函数本身保留(其契约是导入裸进程环境映射,整表 exported 对该契约仍正确),executor 路径改走带出处的新绑定。无其他删除。验证(接手车道复核,2026-11-09)
seeded_names_snapshot_as_not_exported(恰缺陷格)。cargo fmt --checkrc=0(提交头终树)。RUSTFLAGS="-D warnings" rc=0。