refactor(interpreter): fix shell options split brain (#736)#764
Open
refactor(interpreter): fix shell options split brain (#736)#764
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ShellOptionsstruct — shell options (errexit, xtrace, pipefail) were tracked in two independent places: a struct on the Interpreter andSHOPT_*magic variables in the HashMap. Theset/shoptbuiltins could only modify variables, creating split-brain.SHOPT_*variables —is_errexit_enabled(),is_xtrace_enabled(),is_pipefail()now read from a single source of truth instead of OR-ing two sources.ShellStateno longer has separateerrexit/xtrace/pipefailfields; options are captured as part of thevariablesHashMap, ensuring options set viasetsurvive serialization roundtrips.Closes #736
Test plan
shell_options_survive_snapshot_roundtriptest verifying SHOPT_* variables are correctly snapshot/restoredcargo test --all-features)cargo fmt --checkcleancargo clippy --all-targets --all-features -- -D warningsclean