Skip to content

Optimize generate-stackbrew-library.sh by replacing sed in loop with parameter expansion#121

Merged
keeganwitt merged 1 commit into
groovy:masterfrom
keeganwitt:fix-inefficient-sed-in-loop-8280989343786662554
Mar 3, 2026
Merged

Optimize generate-stackbrew-library.sh by replacing sed in loop with parameter expansion#121
keeganwitt merged 1 commit into
groovy:masterfrom
keeganwitt:fix-inefficient-sed-in-loop-8280989343786662554

Conversation

@keeganwitt

Copy link
Copy Markdown
Member

Replaced the inefficient sed call inside the loop with native shell parameter expansion ${dir%"${dir##*[![:space:]]}"} to remove trailing whitespace. This avoids forking a new process for every iteration, improving performance and maintainability. Also removed the now unnecessary shellcheck disable comment.

…parameter expansion

Replaced the inefficient `sed` call inside the loop with native shell
parameter expansion `${dir%"${dir##*[![:space:]]}"}` to remove trailing
whitespace. This avoids forking a new process for every iteration,
improving performance and maintainability. Also removed the now
unnecessary shellcheck disable comment.

Co-authored-by: keeganwitt <64612+keeganwitt@users.noreply.github.com>
@keeganwitt
keeganwitt merged commit b027b63 into groovy:master Mar 3, 2026
22 checks passed
@keeganwitt
keeganwitt deleted the fix-inefficient-sed-in-loop-8280989343786662554 branch March 3, 2026 17:55
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.

1 participant