Repository navigation
parser/executor: encode imported env entries at the entry face (Refs #3207) - #3233
Merged
Merged
Conversation
caomengxuan666
marked this pull request as ready for review
November 10, 2026 04:12
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 #3207
Summary
Entry-encoding contract gap (residual of the #3105 contract, following the #2884 env-import precedent): host-side raw values handed to
SessionBuilderenv seeds and toVariablesView::set/set_array/set_assoclanded in storage unencoded, so a carrier byte (0x1c) in a value was stripped as live protocol at finalization and a marker-zone character was read as live protocol downstream.Executor::set_envis deliberately not the encoding boundary: shell internals hand it cooked values, and encoding there would double-encode.Mechanism
src/executor/env_helpers.rs: factor the per-name channel rule out ofentry_encode_imported_envinto a newpub(crate)helperentry_encode_imported_env_value(name, value)—__RUBASH_*names pass verbatim,BASH_FUNC_*%%names take the SOURCE encoding, every other value takes the DATA encoding.entry_encode_imported_envnow maps through the helper; its behaviour is unchanged.src/api/session.rs: theSessionBuilderbuild loop entry-encodes each env seed beforeset_env. The__RUBASH_SCRIPT_NAMEargv0 line stays verbatim.src/api/views.rs:VariablesView::setentry-encodes the scalar value;set_array/set_assocentry-encode each cell value (the per-name rule keyed on the variable name).Executor::set_env,src/lexer/continuation.rs, anddocs/api-ledger.mdare untouched: no new public face is added.Pin
tests/issue3207_entry_encoding_residual.rs(7 cells, committed first, before the product change): builder seed finalization, builder seed export-to-child, builder seed marker-zone guard,VariablesView::setfinalization,set_arrayfinalization,set_assocfinalization, plain-value round-trip guard.6ace5616: 2 passed / 5 failed — the five carrier-loss cells red with the same signature (storedf\x1cgread back asfc); the marker-zone and plain-value cells green as guards.Verification (batch run B12, captain batch session, 2026-11-10)
issue3207_entry_encoding_residual: 7 passed / 0 failed, with a fresh pin-binary mtime as second evidence.issue2875cell; the head name set is a subset of the base set.session_api7/0,issue288415/0,issue310515/0,issue5909/0 (theissue590stem needs thewindows-shimfeature build so thebashshim binary exists on Linux; with that build all nine cells pass).RUSTFLAGS="-D warnings" cargo check --locked --lib --binsrc=0;python3 scripts/check-marker-literals.pyrc=0;cargo fmt --checkrc=0.本 PR 删除了什么
无产品代码删除。
entry_encode_imported_env原有的内联按名分支被抽出为共享 helper,原逻辑逐字保留在新 helper 中,属于行为不变的重构。