fix(expansion): apply ${@/#/prefix} per positional param#1247
Merged
Conversation
10fcf68 to
9743a67
Compare
…param
Three fixes:
1. Per-element operators (prefix/suffix strip, replace, case) now apply
to each positional parameter individually instead of the joined string
2. ${var/#/rep} and ${var/%/rep} with empty anchored pattern now correctly
prepend/append the replacement (was no-op)
3. Variable expansion in ${var/pattern/$replacement} replacement strings
Also works for array[@] subscripts.
Closes #1160
192b882 to
303707e
Compare
…flow The Vec<String> locals in the ParameterExpansion arm bloated the async state machine, causing stack overflow at depth 32 in debug builds. Move the per-element logic into a separate sync method (apply_param_op_maybe_per_element) to keep it off the async frame.
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
${var/#/rep}and${var/%/rep}with empty anchored pattern now correctly prepend/append the replacement (was a no-op)${var/pattern/$replacement}replacement strings now works${array[@]/#/prefix}subscriptsTest plan
${@/#/tag_}prepends to each positional param${@/%/.html}appends to each positional param${@#tag_}strips prefix from each positional param${@/#/$var}expands variable in replacementcargo clippycleanCloses #1160