fix(scripts): make create-github-issues.sh compatible with macOS#82
fix(scripts): make create-github-issues.sh compatible with macOS#82
Conversation
… 3.2 - Replace declare -A (bash 4+) with file-based key-value storage - Query JSON file directly instead of storing in bash variables (avoids escaping issues with special characters in issue bodies) - Change label delimiter from : to | to support labels like priority:critical - Add error output when issue creation fails Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR Review: Fix bash 3.2 Compatibility for macOSSummaryThis PR successfully addresses macOS compatibility issues by replacing bash 4+ features with bash 3.2-compatible alternatives. The changes are well-implemented and solve real problems. Code Quality & Best Practices ✅Strengths:
Suggestions for improvement:
# Instead of duplicating the gh issue create command:
local gh_args=(--repo "$REPO" --title "$full_title" --body-file "$body_file")
[[ -n "$labels" ]] && gh_args+=(--label "$labels")
[[ -n "$milestone" && "$milestone" != "null" ]] && gh_args+=(--milestone "$milestone")
issue_url=$(gh issue create "${gh_args[@]}" 2>&1)
grep "^${1}=" "$ISSUE_MAP_FILE" 2>/dev/null | cut -d= -f2 | tail -1Potential Issues 🐛
set_issue_map() {
local key="$1" value="$2"
grep -v "^${key}=" "$ISSUE_MAP_FILE" > "${ISSUE_MAP_FILE}.tmp" 2>/dev/null || true
echo "${key}=${value}" >> "${ISSUE_MAP_FILE}.tmp"
mv "${ISSUE_MAP_FILE}.tmp" "$ISSUE_MAP_FILE"
}
if [[ $issue_count -eq 0 ]]; then
echo -e "${YELLOW}No issues to create${NC}"
exit 0
fiPerformance ⚡Good:
Security 🔒Good practices observed:
Testing 🧪Recommendations:
# Requires: bash 3.2+, gh CLI, jq
if [[ "${BASH_VERSINFO[0]}" -lt 3 ]]; then
echo -e "${RED}Error: bash 3.0 or higher required${NC}"
exit 1
fiOverall Assessment ⭐Verdict: Approve with minor suggestions This is a solid fix that solves real compatibility issues. The core changes are well-designed:
The suggestions above are nice-to-haves that would make the script more robust, but they're not blockers. The PR is ready to merge as-is, with optional follow-up improvements. Score: 8.5/10 Great work! 🎉 |
There was a problem hiding this comment.
Pull request overview
This PR makes the create-github-issues.sh script compatible with macOS by addressing bash 3.2 limitations and improving JSON parsing robustness. The issues defined in github-issues.json were successfully created on GitHub (issues #52-#81) and subsequently cleared from the file.
Changes:
- Replaced bash 4+ associative arrays with file-based key-value storage for bash 3.2 compatibility
- Changed JSON parsing to query the file directly instead of passing through bash variables, avoiding escaping issues
- Changed label delimiter from
:to|to support labels containing colons (e.g.,priority:critical) - Cleared the issues array in github-issues.json after successful issue creation with a note documenting what happened
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| scripts/create-github-issues.sh | Refactored to use file-based mapping instead of associative arrays; improved JSON parsing and error handling; fixed label delimiter |
| scripts/github-issues.json | Cleared issues array after successful creation with documentation note |
| declare -A ISSUE_MAP | ||
| # Using a temp file for bash 3.2 compatibility (macOS default) | ||
| ISSUE_MAP_FILE=$(mktemp) | ||
| trap "rm -f $ISSUE_MAP_FILE" EXIT |
There was a problem hiding this comment.
The trap command should quote the variable to ensure proper cleanup even if the path contains spaces. While mktemp typically generates paths without spaces, it's a best practice to quote variables in shell scripts for robustness.
| trap "rm -f $ISSUE_MAP_FILE" EXIT | |
| trap 'rm -f "$ISSUE_MAP_FILE"' EXIT |
| ${labels:+--label "$labels"} \ | ||
| ${milestone_num:+--milestone "$milestone_num"} \ | ||
| 2>&1 | grep -oE '[0-9]+$' || echo "") | ||
| issue_num=$(echo "$issue_url" | grep -oE '[0-9]+$' || echo "") |
There was a problem hiding this comment.
The issue number extraction assumes the URL ends with just the issue number, but if gh issue create fails, the error message in issue_url might contain numbers that get incorrectly extracted. For example, an error like "rate limit exceeded, try again in 60 seconds" would extract "60" as the issue number. Consider checking if the issue_url contains "github.com" before attempting to extract the number, or check the exit code of gh issue create separately.
| body_file=$(mktemp) | ||
| echo "$body" > "$body_file" |
There was a problem hiding this comment.
The body_file temporary file is created but may not be cleaned up if the script exits unexpectedly between lines 244 and 269. Consider adding a trap for this temp file similar to the ISSUE_MAP_FILE, or use a cleanup pattern that ensures removal even on early exit.
Summary
declare -Awith file-based storage)priority:criticalTest plan
--dry-runflag🤖 Generated with Claude Code