feat(interpreter): implement BASH_SOURCE array variable#832
Merged
Conversation
Closes #825 — add BASH_SOURCE tracking via bash_source_stack field on Interpreter. Updated in execute_script_content, execute_source, and execute_function_call to maintain source file stack. BASH_SOURCE[0] reflects the current source file, with depth increasing for nested source/function calls. Supports the common source guard pattern: `[[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@"`
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
bash_source_stack: Vec<String>field to Interpreter[[ "${BASH_SOURCE[0]}" == "$0" ]]Test plan
bash_source_set_in_script— BASH_SOURCE[0] set when executing script by pathbash_source_set_in_sourced_file— BASH_SOURCE[0] set when sourcingbash_source_guard_direct_execution— guard detects direct executionbash_source_guard_sourced— guard detects sourced contextCloses #825