Repository navigation
WIP: startup shape from own argv, not inherited carriers (rubash#2129, #2133) - #2138
Merged
Merged
Conversation
…(rubash#2129, #2133) run_startup_files chose its branch by reading the __RUBASH_INTERACTIVE / __RUBASH_LOGIN_SHELL env carriers, which an interactive parent exports to every child (Executor::set_env mirrors __RUBASH_* into the process env). A -c child that merely inherited both markers adopted the parent's interactive-login shape, re-sourced the startup chain, and — with an rc/profile line that respawns the shell (fzf's completion procsub) — recursed without bound. GNU decides startup behavior from the invocation itself: shell.c:540-549 (interactive only for forced_interactive/-i or the no-operand tty pair), shell.c:497-503 (LOGIN_SHELL only from -l/--login, argv[0] '-' mark in set_shell_name), shell.c:269-270 (no_rc/no_profile are this invocation's own option-parse flags), execute_cmd.c:1576 (execute_in_subshell: a respawned child inherits post-startup state). - OWN_INTERACTIVE_SHELL / OWN_LOGIN_SHELL statics recorded at every own-argv site (-i, -l/--login, argv[0] '-', the tty pair); branch selection, the -c interactive-init gate and the history gate read own shape, never the carriers. - run_startup_files: respawn door first (RESPAWNED_CHILD runs no branch, $BASH_ENV included); an unearned inherited __RUBASH_LOGIN_SHELL carrier is dropped so the logout face (builtins/exit.def:79-90) and children never see it. - #2133: the run-once guard is the process-local STARTUP_FILES_DONE static — as the __RUBASH_STARTUP_FILES_DONE carrier it was exported to children and suppressed a genuine nested login shell's own profile chain. - #2133/F6: run_main strips the intra-process startup-carrier family (__RUBASH_STARTUP_FILES_DONE, __RUBASH_SOURCED_RC, __RUBASH_NO_PROFILE, __RUBASH_NO_RC) consume-on-read before Executor::new imports the environment — the NIU_INVOKED_AS rule — so an inherited suppressor can no longer defeat an explicit -l/-i; only this process's own --noprofile/--norc argv arms re-arm them. Why not filter at spawn: the spawn whitelist is structurally defeated by the unfiltered process_env_pairs() base (compound_exec.rs:767, external_setup.rs:1261, command_substitution.rs:1877) and the input-procsub site's additive .env() inheritance (trap_exec.rs:3249) — the rule belongs at the child's entry decision point.
…#2129, #2133) 15 watchdog-bounded, counter-file pins: marker-injection zero-sourcing (both markers and each single), the P0 repro terminating, own -lc/-ic earning their branches, nested-login double sourcing (#2133), inherited-suppressor vs own argv in both directions (F6), DONE never visible to commands, $BASH_ENV sourced exactly once with a respawn inside it, the logout face in both directions, and the fzf-shaped interactive startup completing exactly once. Baseline: 10 red / 5 green (the greens are the guard pins); fixed: 15/15.
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.
WIP: startup shape from own argv — inherited-carrier recursion fix
What
run_startup_fileschose its branch by reading the__RUBASH_INTERACTIVE/__RUBASH_LOGIN_SHELLenv carriers, which aninteractive parent exports to every child. A
-cchild that merelyinherited both adopted the parent's interactive-login shape,
re-sourced the startup chain, and — with fzf's completion procsub
line in rc/profile — recursed without bound (field report: Android/
Termux, one blocked generation per ~0.15s).
GNU decides startup behavior from the invocation itself
(shell.c:540-549, shell.c:497-503, shell.c:269-270;
execute_cmd.c:1576 for respawned children). The fix keys every
startup-shape decision on this process's own argv plus the explicit
respawn marker, at the child's entry decision point:
own-argv site (
-i,-l/--login, argv[0]-, the tty pair);branch selection and the
-cinit/history gates read own shape.child runs no branch, $BASH_ENV included.
__RUBASH_LOGIN_SHELLcarrier is dropped,so the logout face and this process's children never see it.
is stripped consume-on-read at run_main entry (the NIU_INVOKED_AS
rule), so an inherited
__RUBASH_NO_PROFILE/__RUBASH_NO_RC/__RUBASH_STARTUP_FILES_DONE/__RUBASH_SOURCED_RCcan no longerdefeat this process's own explicit
-l/-i; only its own--noprofile/--norcargv arms re-arm the suppressors.Spawn-side filtering is not the rule: the spawn whitelist is
structurally defeated by the unfiltered
process_env_pairs()base(compound_exec.rs:767, external_setup.rs:1261,
command_substitution.rs:1877) and the input-procsub site's additive
.env()inheritance (trap_exec.rs:3249). Full census and provenancein the cluster REPORT (bisect redo: the adoption wiring dates to
29da109, 2026-10-10, rubash#487 — the live exposure is the niu
Session-migration composition; a niu-side funnel fix is specified
separately and not in this PR).
Verification
tests/issue2129_startup_carrier_recursion.rs: 15/15 on thefixed tree; 10 red / 5 green on baseline (greens are the guard
pins). Watchdog-bounded, counter-file generation counting.
rebuilt d15a02d 11 red.
issue1830, issue1852, debugger_flag_gnu_parity,
issue1076_startup_variables, bin login_shell_tests, niubash_404
exit-echo pin. One adjacent pre-existing red
(
issue_1306_dash_c_mode_leaves_bash_source_unset) failsidentically on pristine master — not this diff.
Refs #2129(引擎侧;niu 宿主漏斗面由 niubash 配套 PR 承载关单)
Fixes #2133