Repository navigation
fix(executor): convert kept dynamic tempenv binds under posix special builtins (Refs #2771) - #3683
Merged
Merged
Conversation
… builtins (Refs #2771) GNU merge_temporary_env (variables.c:4662) pops the tempvar before its bind_variable replay, so a kept SECONDS=/RANDOM= prefix on a posix special builtin reaches the dynamic assign hook. The rubash keep arms replayed apply_shell_assignment while the frame registration still shadowed the cell — dynamic_bind_targets_plain_cell stood the hook down and the value landed on a plain static cell. Retire the name's frame registration and pre-bind snapshot inside convert_kept_tempenv_dynamic_binds before the replay (the pop GNU performs), and run the conversion on the in-function keep arm in command_dispatch that never called it.
caomengxuan666
added a commit
that referenced
this pull request
Nov 15, 2026
fix(executor): re-derive POSIX mode on POSIXLY_CORRECT bind (Refs #3661) GNU `sv_strict_posix` (variables.c:5820, 6257-6266) fires on every bind/unbind of POSIXLY_CORRECT, not only on `set -o posix`. rubash split the two directions: `apply_posix_mode_transition` keeps the `set -o` path's variable binding; new `sync_posix_mode_from_variable` only re-derives the mode and never writes the variable. Hooks sit at every bind/unbind funnel. Written-text keying (expr.c:352, printf.def:112-113): arithmetic-element and printf-element spellings do NOT flip the mode; statement-element and declare/local-element operands DO. Refs #3661 (the #2902 §2 gate: modernish dies rc=128 in capability detection because a runtime `POSIXLY_CORRECT=1` assignment never armed posix mode). #3661 stays open until the captain hand-closes it on this merge; the #2902 re-run is dispatchable after that. ## 本 PR 删除了什么 No product code or files are deleted. The fix commit is +194/−3 across 12 source files (the −3 is the refactored transition body in `options.rs`). The nail-correction commit rewrites the expectations of 4 existing nail cells and the file header's probe summary, per GNU-oracle evidence; no nail cell was removed (one was added: `temp_prefix_special_builtin_persists`). ## Captain verification (merge round R4, head 5e816ac, base 35437c4) - Pin `issue3661_posixly_correct_runtime_hook_regressions`: 21/21 green on the merged shape (fail-first banked at delivery: 17 red / 3 green on base; GNU oracle matrix 25/25 SAME; neighbors 20 stems / 55 cells banked). - `RUSTFLAGS="-D warnings" cargo check --locked --lib --bins`: rc=0, zero warnings. `rustfmt --check` on all 13 changed .rs files: rc=0. - Full lib bilateral banked at delivery: 1249/0/4 both sides, failure name-set diff empty. - CI on the R4 head (run 43723537799, head == 5e816ac): 3 failing jobs (Rust tests, Rust tests (macOS), GNU regression goldens and canaries), each failing ONLY on the issue2875 baseline cell (`api::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell`); niu-canary success. PASS comment 6894681605 stands. - Intersection (merge-base 2e02e90..35437c4 vs the PR's 13 files): exactly the 3 captain-released files — command_prepare.rs (tip #3482, ~3,900 lines apart), temporary_assignments.rs (tip #3683 @@ -827 vs PR @@ -1460, ~600 lines, different functions), variable_state.rs (tip #3667 pure insertions in different functions). Rebase clean, zero conflicts. - Zero-intersection exception for the tip move after R4: the tip moved 35437c4 -> fc1b848 (user merged #3682, Refs #3189) while R4's legs were banked; the increment touches exactly one file, `src/executor/conditional/extglob.rs`, which is not among the PR's 13 files (programmatic intersection: 0). The merged tree is therefore the R4-verified shape plus #3682's file only; no update-branch re-verify round is required. #3682's own CI was captain-named baseline-only (run 43721665167).
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.
【WIN-AGENT-FIX】
Problem
Under
set -o posix, a tempenv prefix on a special builtin is kept rather than restored. Kept dynamic names (SECONDS,RANDOM, …) must convert to a real dynamic bind:SECONDS=100 :should leave$SECONDSticking from 100, andRANDOM=7 :should seed the generator. Pinissue2771_posix_function_tempenv_conversionhad 4 red cells: the in-function keep arm never converted, and the top-level keep converted into a static plain cell (100forever).Root cause
GNU
merge_temporary_env(variables.c:4662) pops the tempvar before itsbind_variablereplay, so the dynamic assign hook fires on the kept value. Rubash replayedapply_shell_assignmentwhile the name was still registered in the live tempenv frame —dynamic_bind_targets_plain_cellsaw the shadow, stood the hook down, and the value landed on a second plain cell. Additionally the in-function keep arm incommand_dispatchnever invoked the conversion at all.Fix
convert_kept_tempenv_dynamic_binds: before the replay, remove the name's registration in the current tempenv frame (above the last mark) and drop the frame's pre-bind snapshot — the pop GNU performs.command_dispatchin-function posix keep arm: callconvert_kept_tempenv_dynamic_binds(&merge_names)aftermerge_converted_tempenv_bindings.Legs
issue2771_posix_function_tempenv_conversion: 4 red on master → 5/5 greenin-f:100 / in-g:100 / in-f2:101 / top-after:102 / draws:19344,26956)issue3211reds reproduce on pristine master (regression fromeaa357fc, unrelated — pre-existing)RUSTFLAGS=-D warnings cargo build --lockedclean