fix(builtins): handle quoted assignment arguments in declare#1147
Open
lu-zero wants to merge 1 commit into
Open
fix(builtins): handle quoted assignment arguments in declare#1147lu-zero wants to merge 1 commit into
lu-zero wants to merge 1 commit into
Conversation
Performance Benchmark Report
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is Test Summary: bash-completion test suite
|
7af336b to
7e011dd
Compare
Owner
|
Thanks for putting this together; I hit this while looking at bash completion tests. |
7e011dd to
59dffc7
Compare
Elsie19
suggested changes
May 8, 2026
Comment on lines
+353
to
+357
| if let brush_core::CommandArg::String(s) = declaration { | ||
| if let Some((_name, value)) = s.split_once('=') { | ||
| return value.starts_with('('); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
This can be collapsed:
Suggested change
| if let brush_core::CommandArg::String(s) = declaration { | |
| if let Some((_name, value)) = s.split_once('=') { | |
| return value.starts_with('('); | |
| } | |
| } | |
| if let brush_core::CommandArg::String(s) = declaration | |
| && let Some((_, value)) = s.split_once('=') | |
| { | |
| return value.starts_with('('); | |
| } |
Contributor
Author
There was a problem hiding this comment.
sure, let me fold it in. Thank you :)
When declare receives a single-quoted argument like 'arr=()', the
parser cannot recognize it as an AssignmentWord (leading quote is not a
valid variable name start). After word expansion strips the quotes, the
builtin receives CommandArg::String("arr=(${X})") but never detected
the = sign, treating the entire string as a variable name and failing
validation.
Extend declaration_to_name_and_value to split on = for CommandArg::String
args, handling both name=value and name[index]=value patterns. For scalar
values the expanded string is used as-is (word expansion already handled
quoting correctly). For array values with -a, add lift_string_array_assignment
that reconstructs a declare command and runs it through the shell to let
the parser and expander handle array parsing and parameter expansion at
runtime.
This fixes the Gentoo rpm.eclass pattern:
IFS=, declare -a 'types=()'
ba20ad1 to
2417eff
Compare
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.
When declare receives a single-quoted argument like 'arr=()', the parser cannot recognize it as an AssignmentWord (leading quote is not a valid variable name start). After word expansion strips the quotes, the builtin receives CommandArg::String("arr=(${X})") but never detected the = sign, treating the entire string as a variable name and failing validation.
Extend declaration_to_name_and_value to split on = for CommandArg::String args, handling both name=value and name[index]=value patterns. For scalar values the expanded string is used as-is (word expansion already handled quoting correctly). For array values with -a, add lift_string_array_assignment that reconstructs a declare command and runs it through the shell to let the parser and expander handle array parsing and parameter expansion at runtime.
This fixes the Gentoo rpm.eclass pattern:
IFS=, declare -a 'types=()'