Skip to content

builtins: migrate the remaining diagnostic prefix faces onto the shared argv0 chain - #3356

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/3256-prefix-chain-migration
Nov 11, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/3256-prefix-chain-migration

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

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 in builtins::prefix:

  • builtins::prefix gains a sys_error_prefix renderer (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).
  • Lib Prolog faces — alias.rs, set.rs::prolog_for_env, setattr.rs, set/unset.rs, and PrologParts::Lib in executor/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/unalias now 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 in executor/read_helpers.rs) derives every arm from the chain; the eval frame's eval: 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 删除了什么

  • The literal-prefix shim in executor/trap_exec.rs (execute_exec's no-operand path): it rewrote buffered builtin stderr beginning with the literal rubash: 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 private error_file_name helper, subsumed by the chain's renderer inputs.
  • Two expectation cells in 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 PROGRAM bash. This is a deliberate expectation change following the migration ruling, recorded here rather than silently edited.
  • Two expectations in tests/executor_command_chaining/part_023.rs (test_cd_redirects_stderr, test_cd_appends_stderr): under the bare Executor::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-coded rubash: 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 neighbouring times expectations in part_024.rs fail identically on both trees — a pre-existing, environment-sensitive red outside this wave's faces — and are untouched.

Evidence

  • New regression pin 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.
  • Fail-first, base 20ba3aea with 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.
  • The eval arm of builtin_error_prefix has 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.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant