fix(interpreter): expand assoc array keys with command subs, fix set -e in compound commands#874
Closed
fix(interpreter): expand assoc array keys with command subs, fix set -e in compound commands#874
Conversation
…-e in compound commands Fix #872: Add async expand_assoc_key() that uses full word expansion (parse_word_string + expand_word) for associative array keys containing $() or backtick substitutions, replacing the sync-only expand_variable_or_literal() in process_command_assignments(). Fix #873: Check result.errexit_suppressed in execute_script_body() so compound commands (for/while/until) whose body ends with an AND-OR chain failure do not incorrectly trigger set -e.
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
$(...)) were expanding to empty strings. Added asyncexpand_assoc_key()that uses full word expansion (parse_word_string+expand_word) instead of the sync-onlyexpand_variable_or_literal()inprocess_command_assignments().set -eincorrectly triggered on compound commands (for/while/until) whose body ended with an&&chain failure. Fixed by checkingresult.errexit_suppressedinexecute_script_body()alongside the existingCommand::Listand negated pipeline checks.Test plan
assoc_key_command_substitution— verifiesm["$(echo hello)"]="world"expands key tohelloassoc_key_variable_expansion— verifiesm[$key]still worksassoc_key_literal_unchanged— verifies bare literal keys unchangedset_e_for_loop_and_chain_no_exit— reproduces exact issue set -e incorrectly triggers on compound commands whose body ends with && chain failure #873 scenarioset_e_while_loop_and_chain_no_exit— while loop variantset_e_plain_failure_in_loop_still_exits— ensuresset -estill works for non-AND-OR failuresset_e_and_or_testspass (9/9)