Skip to content

fix(executor): attribute Lib/stdio diagnostic prologs to the frame file (Refs #3048) - #3711

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/3048-diagnostic-frame-attribution
Nov 15, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/3048-diagnostic-frame-attribution

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

  • rubash#3048: residual Lib/stdio script_file compositions (PrologParts::Lib, set/unset/setattr diag_prolog, set/shopt prolog_for_env, alias/exit/shift process-env arms) read __RUBASH_SCRIPT_NAME alone — an error inside a function defined in a sourced file paired the frame's line with the top-level script's name
  • GNU builtins/common.c:83-94 builtin_error → error_prolog → get_name_for_error (error.c:90-120) = BASH_SOURCE[0]; execute_cmd.c:5310-5313 execute_function pushes the definition file
  • Fix: export prefix::error_file_name (__RUBASH_CURRENT_FILE → __RUBASH_SCRIPT_NAME, the same pairing Executor::current_error_file_name composes) and route all 8 remaining compositions through it — unset -Z/readonly 9bad=v inside a sourced function now report ./lib.sh: line 1:

Test plan

  • tests/issue3048_diagnostic_prefix_residuals.rs — 16/16 green (was 14/16; unset + readonly residuals now correct)
  • Nested-source probe ./lib2.sh: line 1: byte-identical to WSL GNU bash 5.3.20
  • Predecessor pins green: issue3035 (7), issue2212 (14), issue3256, issue2791, issue1768/3355 failures are pre-existing argv0-face deltas identical on base

Generated with Devin

…le (Refs #3048)

GNU builtins/common.c:83-94 builtin_error -> error_prolog names
get_name_for_error (error.c:90-120) = BASH_SOURCE[0]; at a function
call the innermost frame's source is the function's DEFINITION file
(execute_cmd.c:5310-5313 execute_function pushes the recorded
source_file). The executor stamps that composed view per command into
the __RUBASH_CURRENT_FILE carrier (rubash#3035), and
builtins::prefix::error_file_name composes CURRENT_FILE ->
SCRIPT_NAME — but the residual Lib/stdio prolog compositions
(PrologParts::Lib, set/unset diag_prolog, setattr diag_prolog,
set/shopt prolog_for_env, and the alias/exit/shift process-env arms)
still read __RUBASH_SCRIPT_NAME alone, pairing the frame's line with
the top-level script's name (`unset -Z` inside a sourced function
reported `drv.sh: line 1` instead of `./lib.sh: line 1`).

Route every remaining script_file composition through
prefix::error_file_name (made pub(crate)) so all prolog faces share
one pairing with Executor::current_error_file_name.

Pin: tests/issue3048_diagnostic_prefix_residuals.rs 16/16 green
(unset invalid-option + readonly invalid-id were the last live
residuals; top-level and own-file controls unchanged). Nested-source
probe (`./lib2.sh: line 1`) byte-identical to WSL GNU bash 5.3.20.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666
caomengxuan666 merged commit d687ae9 into master Nov 15, 2026
7 of 11 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/3048-diagnostic-frame-attribution branch November 15, 2026 17:35
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