Repository navigation
builtins: migrate the remaining diagnostic prefix faces onto the shared argv0 chain - #3356
Merged
Merged
Conversation
…ed argv0 chain Refs #3256 The (b) wave of the prefix convergence: every diagnostic face that still derived its name privately now derives it from the single argv[0] carrier chain in builtins::prefix (rubash#2791), the way GNU derives every diagnostic name from the one get_name_for_error (error.c:90-120): $0 verbatim for non-interactive shells, the script name for script frames, base_pathname(shell_name) for interactive shells (shell.c:1797/1804). - builtins::prefix gains a sys_error renderer (error.c:275-281: error_prolog(0) — the name alone, never a line segment). - builtins/diagnostic.rs: the diagnostic / sys_error / err_readonly builders delegate to the chain behind the interactive arm, replacing the hard-coded "rubash: " fallback for incomplete carrier pairs. - The Lib Prolog faces (alias, set's prolog_for_env, setattr, unset, PrologParts::Lib in builtin_diag): the error name comes from the chain and the interactive name is the basename derivation, not the shell-name carrier verbatim. - alias/unalias take the dispatcher's composed prolog: the lib prolog reads the process env, whose carriers cannot express the interactive arm (rubash#2259), which is why interactive alias printed the literal name plus a spurious line segment. - builtins::set::builtin_error_prefix (the TIMEFORMAT diagnostic's prefix) derives every arm from the chain; the eval frame's segment, which the chain has no counterpart for, keeps its shape. - setattr's readonly prefix delegates to the chain's err_readonly renderer outside the interactive arm. Regression pin: tests/issue3256_renamed_prefix_matrix.rs — the renamed matrix (arg0 rename, path-invoked renamed copy, script forms, interactive forms) across the lib-reachable faces, with expectations taken from the GNU 5.3.20 renamed-matrix experiment recorded in the issue dossier.
…ation Refs #3256 test_cd_redirects_stderr / test_cd_appends_stderr asserted the cd diagnostic under the bare Executor::new() embedding contains "rubash: cd:". That embedding carries a line but no file/name carrier: the old builtin face fell back to its hard-coded "rubash: " for every incomplete carrier pair, while the shared chain (builtins::prefix) renders its line-only arm from the terminal fallback — "bash: line 1: cd: ..." — the same shape the executor's own prefix locks for this embedding. The (b) migration therefore changes these two expectations, recorded here and in the PR body rather than silently edited. Verified bilaterally: both tests pass on the base tree and failed on the migrated tree until this alignment; the neighbouring times expectations in part_024 fail identically on both trees (a pre-existing, environment-sensitive red outside this wave's faces) and are untouched.
This was referenced Nov 11, 2026
caomengxuan666
marked this pull request as ready for review
November 11, 2026 13:50
This was referenced Nov 11, 2026
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 #3256
What this wave does
The (b) wave of the diagnostic-prefix convergence. The first wave landed the faces that could converge byte-for-byte against the executor's existing prefix; the ten faces that had to wait each derived their diagnostic name privately — a hard-coded
rubash:fallback, the shell-name carrier printed verbatim as the interactive name, or a process-env prolog that cannot see the interactive carrier at all. A renamed-shell experiment against the GNU 5.3.20 oracle (recorded in the issue dossier) showed GNU has exactly one name source for all of these faces (error.c:90-120 get_name_for_error;shell.c:1797/1804), and measured four divergence classes at the CLI. This PR migrates every remaining face onto the single argv[0] carrier chain inbuiltins::prefix:builtins::prefixgains asys_error_prefixrenderer (error.c:275-281: name segment only, never a line segment).builtins/diagnostic.rs— the diagnostic / sys_error / err_readonly builders delegate to the chain behind the interactive arm (basename, no line segment).alias.rs,set.rs::prolog_for_env,setattr.rs,set/unset.rs, andPrologParts::Libinexecutor/builtin_diag.rs: the error name comes from the chain's fallback derivation and the interactive name cell holds the basename derivation instead of the raw shell-name carrier.alias/unaliasnow take the dispatcher's composed prolog (Executor::diagnostic_prolog), for the same dispatcher-owns-the-prolog reason as the Stage-2 ④ D3 migration: the lib prolog reads the process env, and the interactive carrier is never mirrored there.builtins::set::builtin_error_prefix(production consumer: the TIMEFORMAT diagnostic inexecutor/read_helpers.rs) derives every arm from the chain; the eval frame'seval:segment, which has no chain counterpart, keeps its existing shape.setattr.rs's readonly prefix delegates to the chain's err_readonly renderer outside the interactive arm.本 PR 删除了什么
executor/trap_exec.rs(execute_exec's no-operand path): it rewrote buffered builtin stderr beginning with the literalrubash:to the executor's prefix. The builtin face now derives the same prefix from the same carriers through the shared chain, so the literal it matched can no longer be produced; the rewrite is removed rather than left as dead code. The script-form bare-exec cells of the new pin (and of the first wave's pin) cover the path it served.builtins/diagnostic.rs's privateerror_file_namehelper, subsumed by the chain's renderer inputs.tests/executor_tests.rs(builtin_error_prefix_three_modes_match_gnu) that encoded the old hard-coded fallback name: the line-only and carrier-less arms now end at the chain's terminal fallback, GNU's PROGRAMbash. This is a deliberate expectation change following the migration ruling, recorded here rather than silently edited.tests/executor_command_chaining/part_023.rs(test_cd_redirects_stderr,test_cd_appends_stderr): under the bareExecutor::new()embedding (a line carrier but no file/name carrier) the cd diagnostic now renders the chain's line-only arm,bash: line 1: cd: ..., instead of the old face's hard-codedrubash:fallback — the same shape the executor's own prefix locks for this embedding. Verified bilaterally (both pass on the base tree; both failed on the migrated tree until this alignment). The neighbouringtimesexpectations inpart_024.rsfail identically on both trees — a pre-existing, environment-sensitive red outside this wave's faces — and are untouched.Evidence
tests/issue3256_renamed_prefix_matrix.rs(whole stem#![cfg(unix)], like its sibling stem): renamed invocations (arg0 rename; a physically copied binary invoked by absolute path) across the lib-reachable faces (alias, export, readonly, unset, exec, cd's sys_error face, the TIMEFORMAT face) in -c, script, and interactive forms, plus direct calls of the public prefix face. Expectations are the GNU 5.3.20 outputs from the dossier's renamed-matrix experiment.20ba3aeawith the pin topped up: 3 passed / 6 failed — the interactive cells and the chain cells fail with the literal name, the verbatim full path, and the spurious line segment; the -c and script cells pass on both sides (the startup seed already fed those faces the invocation name) and lock the migration against regression. On this head: 9 passed / 0 failed.builtin_error_prefixhas no chain counterpart and no GNU interactive measurement behind it; it is pinned in its existing shape only (script + line + eval carriers), and that limitation is stated in the wave's report section rather than presented as coverage.