Skip to content

fix(expansion): apply ${@/#/prefix} per positional param#1247

Merged
chaliy merged 4 commits intomainfrom
fix/issue-1160-positional-param-substitution
Apr 13, 2026
Merged

fix(expansion): apply ${@/#/prefix} per positional param#1247
chaliy merged 4 commits intomainfrom
fix/issue-1160-positional-param-substitution

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 13, 2026

Summary

  • Per-element operators (prefix/suffix strip, replace, case) now apply to each positional parameter individually instead of the joined string
  • ${var/#/rep} and ${var/%/rep} with empty anchored pattern now correctly prepend/append the replacement (was a no-op)
  • Variable expansion in ${var/pattern/$replacement} replacement strings now works
  • Also works for ${array[@]/#/prefix} subscripts

Test plan

  • ${@/#/tag_} prepends to each positional param
  • ${@/%/.html} appends to each positional param
  • ${@#tag_} strips prefix from each positional param
  • ${@/#/$var} expands variable in replacement
  • All 15 spec test suites pass (no regressions)
  • cargo clippy clean

Closes #1160

@chaliy chaliy force-pushed the fix/issue-1160-positional-param-substitution branch from 10fcf68 to 9743a67 Compare April 13, 2026 11:46
chaliy added 3 commits April 13, 2026 17:03
…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
@chaliy chaliy force-pushed the fix/issue-1160-positional-param-substitution branch from 192b882 to 303707e Compare April 13, 2026 17:03
…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.
@chaliy chaliy merged commit 86238d5 into main Apr 13, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-1160-positional-param-substitution branch April 13, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(expansion): ${@/#/prefix} and ${@/%/suffix} do not apply to positional params

1 participant