Skip to content

refactor(interpreter): fix shell options split brain (#736)#764

Open
chaliy wants to merge 1 commit intomainfrom
claude/fix-shell-options-split-brain-PLhL3
Open

refactor(interpreter): fix shell options split brain (#736)#764
chaliy wants to merge 1 commit intomainfrom
claude/fix-shell-options-split-brain-PLhL3

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Mar 18, 2026

Summary

  • Removed ShellOptions struct — shell options (errexit, xtrace, pipefail) were tracked in two independent places: a struct on the Interpreter and SHOPT_* magic variables in the HashMap. The set/shopt builtins could only modify variables, creating split-brain.
  • Unified all option state into SHOPT_* variablesis_errexit_enabled(), is_xtrace_enabled(), is_pipefail() now read from a single source of truth instead of OR-ing two sources.
  • Fixed snapshot/restoreShellState no longer has separate errexit/xtrace/pipefail fields; options are captured as part of the variables HashMap, ensuring options set via set survive serialization roundtrips.

Closes #736

Test plan

  • Added shell_options_survive_snapshot_roundtrip test verifying SHOPT_* variables are correctly snapshot/restored
  • All 2061+ existing tests pass (cargo test --all-features)
  • cargo fmt --check clean
  • cargo clippy --all-targets --all-features -- -D warnings clean

… variables

Shell options previously existed in two places: the ShellOptions struct
(errexit, xtrace, pipefail) and SHOPT_* magic variables in the HashMap.
The set/shopt builtins could only modify variables, creating split-brain
where the same option was tracked in two independent locations.

Now all shell options are stored exclusively as SHOPT_* variables.
This eliminates the dual-source OR checks in is_errexit_enabled(),
is_xtrace_enabled(), and is_pipefail(), and ensures snapshot/restore
correctly captures options set via the set builtin.

Closes #736
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.

refactor: fix shell options split brain between ShellOptions struct and SHOPT_* variables

1 participant