Skip to content

fix(interpreter): keep repl alive after child exit#1338

Merged
chaliy merged 1 commit intomainfrom
fix/repl-child-exit-hook
Apr 18, 2026
Merged

fix(interpreter): keep repl alive after child exit#1338
chaliy merged 1 commit intomainfrom
fix/repl-child-exit-hook

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 18, 2026

What

  • stop nested script and bash -c exits from firing the host REPL on_exit hook
  • keep EXIT-trap execution scoped to the child shell context
  • report a bash-compatible BASH_VERSION and BASH_VERSINFO surface so bash feature gates keep working under bashkit
  • preserve BASH_VERSINFO for path-executed shebang scripts, which run in isolated child shell state
  • add regression coverage for direct script execution, PATH-searched scripts, nested shells, sourced files, child EXIT traps, bash-version compatibility, and shebang-script subprocesses

Why

hs --help can call exit 1 inside the harness script when no help or agent command exists. Bashkit was treating that child exit as a whole-session exit in interactive mode, so the REPL closed instead of returning a failing command status.

While validating the fix, CI exposed two bash compatibility bugs in the harness example path:

  • bashkit reported its crate semver through BASH_VERSION and BASH_VERSINFO
  • path-executed shebang scripts dropped BASH_VERSINFO entirely when subprocess isolation cleared child shell arrays

How

  • split interpreter script execution between EXIT-trap handling and host on_exit hook notification
  • disable host exit-hook notification for nested shell/script execution paths
  • preserve host exit-hook behavior for top-level exit and source
  • replace the crate-version-based bash version surface with a fixed bash-compatible tuple while keeping the machine slot virtual
  • reseed BASH_VERSINFO when path-based script execution resets child shell state to exported env only

Tests

  • added focused hook regressions in crates/bashkit/src/lib.rs
  • added bash-version compatibility regressions in crates/bashkit/src/lib.rs
  • added path-script shebang regressions in crates/bashkit/src/lib.rs
  • cargo test -q test_bash_versinfo_reports_bash_compatible_major --lib
  • cargo test -q test_bash_version_surface_matches_bash_compatible_tuple --lib
  • cargo test -q test_path_script_retains_bash_versinfo_array --lib
  • cargo test -q test_path_script_bash_versinfo_satisfies_bash4_guard --lib
  • cargo test -q test_on_exit_hook --lib
  • cargo test -q test_path_script_exit_runs_child_exit_trap --lib
  • just pre-pr

@chaliy chaliy force-pushed the fix/repl-child-exit-hook branch from f07c8d6 to b996f7f Compare April 18, 2026 07:06
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@chaliy chaliy force-pushed the fix/repl-child-exit-hook branch from b996f7f to 46f0e57 Compare April 18, 2026 15:19
@chaliy chaliy force-pushed the fix/repl-child-exit-hook branch from 46f0e57 to d181275 Compare April 18, 2026 15:32
@chaliy chaliy merged commit 7ee2148 into main Apr 18, 2026
40 of 42 checks passed
@chaliy chaliy deleted the fix/repl-child-exit-hook branch April 18, 2026 15:44
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