Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts env_format_lines to strip all trailing empty entries before printing and changes printf array expansion to avoid unbound parameter issues when the array is empty. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The new trailing-empty-element removal loop is more complex than necessary and uses
${FormattedEnvLines[-1]}, which may be less portable and harder to read; consider a clearer pattern likewhile ((${#FormattedEnvLines[@]} && ! ${FormattedEnvLines[-1]})); do ...or iterating from the end with an index variable. - The condition
[[ ${#FormattedEnvLines[@]} -gt 0 && -z ${FormattedEnvLines[-1]-} ]]should quote the array element ("${FormattedEnvLines[-1]-}") to avoid unwanted word splitting and glob expansion when values contain spaces or special characters. - The
printfcallprintf "%s\n" "${FormattedEnvLines[@]+"${FormattedEnvLines[@]}"}"is unusual and likely collapses the array into a single argument; if the goal is to avoid unbound expansion, a clearer pattern is to guard the call withif ((${#FormattedEnvLines[@]})); then printf '%s\n' "${FormattedEnvLines[@]}"; fi.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new trailing-empty-element removal loop is more complex than necessary and uses `${FormattedEnvLines[-1]}`, which may be less portable and harder to read; consider a clearer pattern like `while ((${#FormattedEnvLines[@]} && ! ${FormattedEnvLines[-1]})); do ...` or iterating from the end with an index variable.
- The condition `[[ ${#FormattedEnvLines[@]} -gt 0 && -z ${FormattedEnvLines[-1]-} ]]` should quote the array element (`"${FormattedEnvLines[-1]-}"`) to avoid unwanted word splitting and glob expansion when values contain spaces or special characters.
- The `printf` call `printf "%s\n" "${FormattedEnvLines[@]+"${FormattedEnvLines[@]}"}"` is unusual and likely collapses the array into a single argument; if the goal is to avoid unbound expansion, a clearer pattern is to guard the call with `if ((${#FormattedEnvLines[@]})); then printf '%s\n' "${FormattedEnvLines[@]}"; fi`.
## Individual Comments
### Comment 1
<location path="scripts/env_format_lines.sh" line_range="123" />
<code_context>
+ break
+ fi
+ done
+ printf "%s\n" "${FormattedEnvLines[@]+"${FormattedEnvLines[@]}"}"
}
</code_context>
<issue_to_address>
**issue (bug_risk):** The current parameter expansion likely collapses all array elements into a single printf argument.
`${FormattedEnvLines[@]+
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| break | ||
| fi | ||
| done | ||
| printf "%s\n" "${FormattedEnvLines[@]+"${FormattedEnvLines[@]}"}" |
Contributor
There was a problem hiding this comment.
issue (bug_risk): The current parameter expansion likely collapses all array elements into a single printf argument.
`${FormattedEnvLines[@]+
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.
…xpansion
Pull request
Purpose
Describe the problem or feature in addition to a link to the issues.
Approach
How does this change address the problem?
Open Questions and Pre-Merge TODOs
Check all boxes as they are completed
Learning
Describe the research stage
Links to blog posts, patterns, libraries or addons used to solve this problem
Requirements
Check all boxes as they are completed
Summary by Sourcery
Adjust environment line formatting to avoid extraneous newlines and handle empty arrays safely.
Bug Fixes: