Skip to content

fix(startup): --debugger runs the bashdb starter and degrades like GNU - #1191

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/debugger-gnu-parity
Oct 23, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/debugger-gnu-parity

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

What was wrong

GNU shell.c:257 maps --debugger to debugging_mode only. Startup then runs the bashdb starter file (start_debugger, shell.c:1547) at three gated sites — before -c (:764), before scripts/stdin readers (:795, behind reading_shell_script || interactive_shell == 0) — and a missing starter prints the diagnostic pair and clears the mode (:1559-1561). The flag never touches extdebug; bashdb's own init does.

rubash instead mapped BOTH --debug and --debugger onto set extdebug in invocation.rs — a code path the main binary never reached (parse_long_options swallowed both names as accepted no-ops). Net effect: a bashdb user got a silent no-op; bashdb under niu --debugger never started; no degradation diagnostic ever fired.

Now

  • --debugger: arms the mode; the four non-interactive drivers attempt the starter before any user command. Search order: BASHDB_START_FILE (documented seam — GNU bakes a per-build prefix we cannot know: Termux, custom --prefix), then /usr/local/share/bashdb/bashdb-main.inc, then /usr/share/bashdb/bashdb-main.inc.
  • Miss → GNU-shaped pair: rubash: <path>: No such file or directory + rubash: warning: cannot start debugger; debugging mode disabled, mode cleared.
  • Found → sourced via the normal init-file machinery; its shopt -s extdebug takes effect (that IS how real bashdb arms itself), so a bashdb user upgrades in place.
  • Bare interactive shells skip the attempt exactly like shell.c:795.
  • --debug: stays the vestigial GNU flag it actually is (shell.c:255 debugging var, no user-visible effect). Native script debugger (rubash --debug / --dap): M0 design consensus #497's native debugger owns that name when it lands.

Oracle

WSL GNU bash 5.3.20 (no bashdb installed):

$ bash --debugger -c 'shopt -p extdebug; echo AFTER'
bash: /usr/local/share/bashdb/bashdb-main.inc: No such file or directory
bash: warning: cannot start debugger; debugging mode disabled
shopt -u extdebug
AFTER

rubash now emits the same shape (rubash: prefix per our naming convention), and 6 regression cases in tests/debugger_flag_gnu_parity.rs pin: miss warn+disable, seam path reporting, found-starter sourcing order (starter before -c), no-flag silence, --debug vestigial (rc anchored on echo — GNU's own shopt -p on an OFF option exits 1, verified side by side), stdin-script coverage.

lib 789 ✓ / regression 78 ✓ / fmt clean / clippy clean on touched files.

GNU shell.c:257 maps --debugger to debugging_mode only; startup then
runs the configure-baked bashdb starter (start_debugger, called for -c
at :764 and for scripts/stdin at :795 behind the
reading_shell_script||!interactive gate), and a missing starter warns
internally and clears the mode (:1547-1566). The flag never touches
extdebug — bashdb's own init does.

rubash previously mapped BOTH --debug and --debugger onto extdebug in
invocation.rs, a path the main binary never even reached (the
parse_long_options pre-scan silently swallowed both names): a bashdb
user got silent no-op, everyone else got nothing.

Now: --debugger arms the mode, the four non-interactive driver entry
points attempt the starter (BASHDB_START_FILE seam first — GNU bakes a
per-build prefix we cannot know, Termux included — then the two
conventional locations), a miss prints the GNU-shaped diagnostic pair
and disables the mode, and a bare interactive shell skips the attempt
exactly like shell.c:795. --debug stays the vestigial GNU flag it is
(shell.c:255), accepted with no effect; #497's native debugger owns
that name when it lands.

Verified against the WSL GNU bash 5.3.20 oracle transcript in
tests/debugger_flag_gnu_parity.rs (6 cases: miss warn+disable, seam
path reporting, found-starter sourcing order, no-flag silence, --debug
vestigial, stdin-script coverage).
@caomengxuan666
caomengxuan666 merged commit 8a4426b into master Oct 23, 2026
8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/debugger-gnu-parity branch October 23, 2026 08:54
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